<style scoped>
.policy-edit{
    padding-bottom: 35px;
    
}

.pro-list{
    padding-top: 10px;
}
.pro-list h4{
    display: block;
    position: relative;
}

.pro-list h4:before{
    content: '';
    position: absolute;
    height: 0;
    top:8px;
    left: 0;
    width: 100%;
    border-bottom: 1px dotted #d9d9d9;
    
}
.pro-list h4 span{
    display: inline-block;
    background: #fff;
    padding-left: 5px;
    padding-right: 5px;
    position: relative;
    font-weight: normal;
}
.import-left{
    background-color: #f2f2f2;
    overflow: hidden;
}
.import-search{
    padding: 15px 15px 0;
}
.import-list{
    padding: 0 13px;
}
.import-right{
    background-color: #cfebf9;
    padding: 20px 20px 0 20px;
}
.import-right-title{
    overflow: hidden;
}
.import-right-title h3{
    display: inline-block;
    color: #ef8411;
    font-size: 16px;
    line-height: 43px;
}
.import-right-body{
    padding-top: 20px;
    margin-right: -15px;
}
.import-right-body .ivu-form-item{
    margin-bottom: 24px;
}
.import-search .ivu-input-group-append button{
    background-color: #4074e1;
    color: #fff;
}
.import-search .ivu-input-group{
    top: 0;
}
.pd35{
    padding-bottom: 35px;
}
.form-box{
    position: relative;
    overflow: hidden;
}
.fixed-bottom{
    padding-top: 18px;
    height:80px;
    position:fixed; 
    left:210px;
    right:0; 
    bottom:0; 
    z-index: 999;
    text-align: center;
    background-color: rgb(255, 255, 255); 
    box-shadow: 0px 0px 9px 0px rgba(0, 0, 0, 0.28);
}
.sidehide{
    left: 75px;
}
.benefit{
    margin-bottom: 15px;
}
.reset{
    background-color: #5cadff !important;
}
.slot-footer{
    background-color: #f2f2f2;
    overflow: hidden;
    margin: -12px -18px;
    padding: 12px 18px;
}
.bgfff{
    background-color: #fff;
}
.pro-box{
    padding-top: 20px;
    padding-left: 20px;
}
.party-box{
    margin: -16px;
    background-color: #cfebf9;
}
.total-price{
    color: red;
    font-size: 16px;
}
.common-form-body-left{
    float: left;
    width: 75%;
    overflow: hidden;
}
.common-form-body-right{
    float: right;
    width:25%;
    padding:0;
    border-radius: 0 2px 2px 0;
}
.common-form-body-right.checkbox {
    border: none !important;
    text-align: center;
    width:25%;
    background-color: #fff;
}
.insured-box-title{
    height: 35px;
    line-height: 35px;
    background-color: #f4f4f4;
    padding: 0 10px;
    margin: 0 0 15px 0;
}
.insured-box-title-right{
    float: right;
    margin-right: 15px;
    color: #ed3f14;
    cursor: pointer;
}
.insured-box-title-right-i{
    margin-right: 5px;
}
</style>
<style>
.clearfix:after {
    visibility: hidden;
    display: block;
    content: " ";
    clear: both;
    height: 0;
    line-height: 0;
}

.clearfix {
    zoom: 1;
}
.table-theme .ivu-table-row-highlight .importbtn{
    background-color: #fff;
    color:#fff;
}
</style>

<template>
    <div class="policy-edit">
        <product-title></product-title>
        <div class="form-box">
            
            <div class="mt20 pro-person">
                <Tabs type="card" :animated=false   v-model="tabName">
                    <TabPane label="保单录入" name="name">
                        <div class="common-box-body common-form-body">
                            <Form ref="policyform1" :model="policyform" :rules="policy_ruleValidate">
                                <Row>
                                    <Col :xs="24" :sm="24" :md="12" :lg="8">
                                        <FormItem prop="yun_org_mid" label="归属机构">
                                            <Select ref="orgselect"  filterable  placeholder="请选择分支机构" v-model="policyform.yun_org_mid" :transfer=true>
                                                <Option v-for="item in orglist" :value="item.id" :key="item.id">{{item.shortn}}</Option>                                                                                                                                       
                                            </Select>
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="12" :lg="8">
                                        <FormItem>
                                            <RadioGroup v-model="policyform.policy_type">
                                                <Radio label="个人保险单"></Radio>
                                                <Radio label="家庭保险单"></Radio>
                                            </RadioGroup>
                                        </FormItem>
                                    </Col>
                                </Row>   
                            </Form>
                        </div>
                        <div class="common-box-header">
                            <h3>录单员信息</h3>
                            <Button @click="importEnter(1)" :disabled="isOffice" class="fr mt7" type="warning" icon="icon iconfont icon-daoru">导入录单员</Button>
                        </div>
                        <div class="common-box-body common-form-body">
                            <Form ref="entering" :model="entering" :rules="entering_ruleValidate">
                                <Row>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="job_code" label="录单工号">
                                            <Input type="text" v-model="entering.job_code "  placeholder="请导入录单工号" disabled></Input>
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="name" label="录单员姓名">                                
                                            <Input type="text" v-model="entering.name"  placeholder="请导入录单员姓名" disabled></Input>                               
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="12">
                                        <FormItem prop="datetime" label="录单时间">
                                            <DatePicker  type="date" :options="options3"placeholder="请选择录单时间" v-model="entering.datetime" @on-change="datachange($event,entering,'date')"></DatePicker>
                                        </FormItem>
                                    </Col>
                                </Row>   
                            </Form>
                        </div>
                        <div class="common-box-header">
                            <h3>业务员信息</h3>
                            <Button @click="importEnter(2)" class="fr mt7" type="warning" icon="icon iconfont icon-daoru">导入业务员</Button>
                        </div>
                        <div class="common-box-body common-form-body">
                            <Form ref="agent" :model="agent" :rules="agent_ruleValidate">
                                <Row>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="job_code" label="工号">                                
                                            <Input type="text" v-model="agent.job_code"  placeholder="请导入工号" disabled></Input>                               
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="name" label="姓名">
                                            <Input type="text" v-model="agent.name"  placeholder="请导入姓名" disabled></Input>
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="rank_name" label="职级">
                                            <Input type="text" v-model="agent.rank_name"  placeholder="请导入职级" disabled></Input>
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem label="推荐人">                                
                                            <Input type="text" v-model="agent.rec_name"  placeholder="请导入推荐人" disabled></Input>                               
                                        </FormItem>
                                    </Col>    
                                </Row>   
                            </Form>
                        </div>
                    </TabPane>
                    <TabPane label="保单信息" name="policyform">
                        <div class="common-box-body common-form-body">
                            <Form ref="policyform" :model="policyform" :rules="policy_ruleValidate">
                                <Row>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="cid" label="保险公司">
                                            <!-- <Select v-model="policyform.cid" @on-change="companychange($event)" filterable remote label-in-value :remote-method="remoteCom" :loading="proloading"  placeholder="选择保险公司">  
                                                <Option v-for="(option, index) in comoptions" :value="option.value" :key="index">{{option.label}}</Option>                               
                                            </Select> -->
                                            <Select v-model="policyform.cid" label-in-value @on-change="cid_change($event)"  filterable  placeholder="选择保险公司" :transfer=true>  
                                                <Option v-for="(option, index) in comoptions" :value="option.cid" :key="option.cid">{{option.name}}</Option>                               
                                            </Select>
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem label="保单性质">
                                            <Select v-model="policyform.nature" @on-change="natureChange($event)" placeholder="请选择保单性质">
                                                <Option value="1">转正单</Option>
                                                <Option value="2">非转正单</Option>
                                                <Option value="3">参与方案</Option>
                                            </Select>
                                        </FormItem>
                                    </Col>                        
                                    <Col :xs="24" :sm="24" :md="8" :lg="12">
                                        <FormItem prop="name" label="保险计划">                                
                                            <Input type="text" v-model="policyform.name"  placeholder="请填写保险计划名"></Input>                               
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem  label="投保单号码" prop="insure_num">
                                            <Input type="text" v-model="policyform.insure_num"  placeholder="请填写投保单号码"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="policy_num" label="保单号码">
                                            <Input type="text" v-model="policyform.policy_num"  placeholder="请填写承保单号码"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="pay_period" label="交费期间">  
                                            <!-- <Select :disabled="pay_period_disable" v-model="policyform.pay_period" placeholder="请导入交费期间">
                                                <Option v-for="item in policypay_period" :value="item" :key="item">{{item}}</Option>                                   
                                            </Select>                                           -->
                                            <Input disabled class="common-form-body-left" type="text" v-model="policyform.pay_period"  placeholder="请导入交费期间"></Input><Button class="common-form-body-right" @click="openPayperiodModal"  type="primary">添加</Button>  
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="period" label="保险期间">
                                            <Input disabled class="common-form-body-left" type="text" v-model="policyform.period"  placeholder="请导入保险期间"></Input><Button class="common-form-body-right" @click="openPeriodModal"  type="primary">添加</Button>  
                                        </FormItem>
                                    </Col>  
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="pay_type" label="交费方式">
                                            <Select v-model="policyform.pay_type" placeholder="请选择交费方式">
                                                <Option value="期交">期交</Option>
                                                <Option value="一次性交">一次性交</Option>
                                            </Select>
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="premium" label="保费合计">
                                            <Input disabled  type="text" v-model="policyform.premium"  placeholder="请输入保费"></Input> 
                                            <!-- <InputNumber :max="9999999" :min="0" v-model="policyform.premium" placeholder="请输入保费"></InputNumber>   -->
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem label="短期消费型">
                                            <Select v-model="policyform.is_short"  placeholder="请选择是否短期消费型">
                                                <Option value="1">是</Option>
                                                <Option value="2">否</Option>
                                            </Select>
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="insure_datetime" label="投保日期">
                                                <DatePicker type="date" @on-change="datachange($event,policyform,'insure_date')" v-model="policyform.insure_datetime" placeholder="请选择投保日期" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="underwrite_datetime" label="承保日期">
                                                <DatePicker type="date" @on-change="datachange($event,policyform,'underwrite_date')" v-model="policyform.underwrite_datetime" placeholder="请选择承保日期" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="effect_datetime" label="生效日期">
                                                <DatePicker type="date" @on-change="datachange($event,policyform,'effect_date')" v-model="policyform.effect_datetime" placeholder="请选择生效日期" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="receipt_datetime" label="回执日期">
                                                <DatePicker type="date" @on-change="datachange($event,policyform,'receipt_date')" v-model="policyform.receipt_datetime" placeholder="请选择回执日期" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="visit_datetime" label="回访日期">
                                                <DatePicker type="date" @on-change="datachange($event,policyform,'visit_date')" v-model="policyform.visit_datetime" placeholder="请选择回访日期" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="withdraw_datetime" label="撤单时间">
                                                <DatePicker type="date" @on-change="datachange($event,policyform,'withdraw_date')" v-model="policyform.withdraw_datetime" placeholder="请选择撤单时间" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="terminal_datetime" label="终止时间">
                                                <DatePicker type="date" @on-change="datachange($event,policyform,'terminal_date')" v-model="policyform.terminal_datetime" placeholder="请选择终止时间" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col>  
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="settlement_datetime" label="计绩年月">
                                                <DatePicker type="month" format="yyyy-MM" @on-change="datachange($event,policyform,'settlement_date')" v-model="policyform.settlement_datetime" placeholder="请选择计绩年月" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="status" label="保单状态">
                                            <Select :transfer=true v-model="policyform.status" placeholder="请选择保单状态">
                                                <Option value="1">预收件</Option>
                                                <Option value="2">承保件</Option>
                                                <Option value="3">契撤件</Option>
                                                <Option value="4">停效件</Option>
                                                <Option value="5">失效件</Option>
                                                <Option value="6">解约件</Option>
                                                <Option value="7">终止件</Option>
                                            </Select>
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6" v-if="policyform.nature == 3">
                                        <FormItem label="备注">
                                            <Input  type="text" v-model="policyform.nature_remark"  placeholder="请输入备注"></Input> 
                                        </FormItem>
                                    </Col>                                             
                                </Row>   
                            </Form>
                        </div>

                    </TabPane>
                    <TabPane label="交费信息" name="bank">
                        <div class="common-box-header">
                            <h3>交费信息</h3>                            
                        </div>
                        <div class="common-box-body common-form-body ">
                            <Form ref="bank" :model="policyform" :rules="policy_ruleValidate">
                                <Row>                       
                                    <Col :xs="24" :sm="24" :md="8" :lg="12">
                                        <FormItem prop="name" label="开户行名称">                                
                                            <Input type="text" v-model="policyform.bank_account"  placeholder="请填写开户行名称"></Input>                               
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="12">
                                        <FormItem prop="name" label="银行卡号">                                
                                            <Input type="text" v-model="policyform.open_bank"  placeholder="请填写银行卡号"></Input>                               
                                        </FormItem>
                                    </Col>
                                </Row>
                            </Form>
                        </div>
                    </TabPane>
                    <TabPane label="投保人" name="applicant">
                        <div class="common-box-header">
                            <h3>投保人</h3>
                        </div>
                        <div class="common-box-body common-form-body ">
                            <Form ref="applicant" :model="applicant" :rules="applicant_ruleValidate">
                                <Row>                                   
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="name" label="姓名">
                                            <Input class="common-form-body-left" type="text" v-model="applicant.name"  placeholder="请导入姓名"></Input><Button @click="importapplicant(1)" :disabled="hasagent" class="common-form-body-right"   type="warning" icon="icon iconfont icon-daoru">导入</Button>     
                                        </FormItem>
                                    </Col>  
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="id_type" label="证件类型">
                                            <Select  @on-change="applicantIdTypeChange($event)" placeholder="请导入证件类型" v-model="applicant.id_type" :transfer=true placement="top">
                                                <Option value="身份证">身份证</Option>
                                                <Option value="户口本">户口本</Option>
                                                <Option value="护照">护照</Option>
                                                <Option value="军官证">军官证</Option>
                                                <Option value="港澳居民来往内地通行证">港澳居民来往内地通行证 </Option>
                                                <Option value="其他">其他</Option>
                                            </Select>  
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6" v-if="hasIdCard">
                                        <FormItem prop="id_number"  label="证件号码" key="id_number_input">
                                            <Input   @on-change="idcardchange($event,applicant)"  placeholder="请导入证件号码" v-model="applicant.id_number"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6" v-else>
                                        <FormItem prop="id_number" :rules="{ required: true,  message: '请填写证件号', trigger: 'blur' }"  label="证件号码" key="no_id_number" >
                                            <Input   @on-change="idcardchange($event,applicant)"  placeholder="请导入证件号码" v-model="applicant.id_number"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="sex" label="性别">
                                            <Select   placeholder="请导入性别" v-model="applicant.sex">
                                                <Option value="1">男</Option>
                                                <Option value="2">女</Option>
                                            </Select>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="birthdaytime" label="出生日期">
                                             <DatePicker  type="date" @on-change="datachange($event,applicant,'birthday')" v-model="applicant.birthdaytime" placeholder="请导入出生日期" :transfer=true placement="top"></DatePicker>  
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="12">
                                        <FormItem prop="id_effect_datetime" label="证件有效期">
                                             <DatePicker  class="common-form-body-left"  type="date" @on-change="datachange($event,applicant,'id_effect_date')" v-model="applicant.id_effect_datetime" placeholder="请输入证件有效期" :transfer=true placement="top"></DatePicker><Checkbox true-value="1" false-value="0" class="common-form-body-right checkbox" v-model="applicant.id_effect_long">长期有效</Checkbox>  
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="marital" label="婚姻">
                                            <Select :transfer=true  placeholder="请选择" v-model="applicant.marital">
                                                <Option value="">请选择婚姻状况</Option>
                                                <Option value="已婚">已婚</Option>
                                                <Option value="未婚">未婚</Option>
                                                <Option value="已婚有子女">已婚有子女</Option>
                                                <Option value="离异">离异</Option>
                                                <Option value="丧偶">丧偶</Option>
                                            </Select>   
                                        </FormItem>
                                    </Col>  
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="nationality" label="国籍">
                                            <Input    placeholder="请输入" v-model="applicant.nationality"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="education" label="学历">
                                            <Select :transfer=true  placeholder="请选择" v-model="applicant.education">
                                                <Option value="">请选择学历</Option>
                                                <Option value="大专">大专</Option>
                                                <Option value="本科">本科</Option>
                                                <Option value="研究生及以上">研究生及以上</Option>
                                                <Option value="中专">中专</Option>
                                                <Option value="高中">高中</Option>
                                                <Option value="初中">初中</Option>
                                                <Option value="小学">小学</Option>
                                                <Option value="学龄前">学龄前</Option>
                                            </Select>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="height" label="身高(cm)">
                                            <Input    placeholder="请输入" v-model="applicant.height"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="weight" label="体重(kg)">
                                            <Input    placeholder="请输入" v-model="applicant.weight"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="mobile" label="联系电话">
                                            <Input    placeholder="请导入联系电话" v-model="applicant.mobile"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="com_name" label="工作单位">
                                            <Input  type="text" v-model="applicant.com_name"  placeholder="请导入工作单位"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="profession" label="职业/工种">
                                            <Input  type="text" v-model="applicant.profession" placeholder="请导入职业/工种"></Input>   
                                        </FormItem>
                                    </Col>                                      
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="postcode" label="邮编">
                                            <Input  type="text" v-model="applicant.postcode" placeholder="请导入邮编"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="email" label="Email">
                                            <Input  type="text" v-model="applicant.email"  placeholder="请导入Email"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="12" :lg="12">
                                        <FormItem prop="home_address" label="详细地址">
                                            <Input  type="text" v-model="applicant.home_address" placeholder="请导入详细地址"></Input>   
                                        </FormItem>
                                    </Col>                                                        
                                </Row>   
                            </Form>
                        </div>
                    </TabPane>
                    <TabPane label="被保人" name="insuredForm">
                        <div class="common-box-header mt20">
                            <h3>被保人</h3>                                                          
                        </div>
                        <div class="common-box-body common-form-body ">
                            <Form ref="insuredForm" :model="insuredForm" :rules="insured_rule">
                                <Row>                                   
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="insured_relation"  label="与投保人关系">
                                                <Select  v-model="insuredForm.insured_relation" @on-change="insuredRelationChange($event)" placeholder="请选择" :transfer=true >
                                                    <Option value="本人">本人</Option>
                                                    <Option value="配偶">配偶</Option>
                                                    <Option value="父母">父母</Option>
                                                    <Option value="子女">子女</Option>
                                                    <Option value="兄弟姐妹">兄弟姐妹</Option>
                                                    <Option value="其他">其他</Option>
                                                </Select>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="insured_name" label="被保人">
                                                <Input  class="common-form-body-left" type="text" v-model="insuredForm.insured_name"  placeholder="请导入被保人"></Input><Button :disabled="hasagent" class="common-form-body-right" @click="importapplicant(2)"  type="warning" icon="icon iconfont icon-daoru">导入</Button>  
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="insured_id_type" label="证件类型">
                                                <Select @on-change="insuredTypeChange($event)"  placeholder="请选择证件类型" v-model="insuredForm.insured_id_type" :transfer=true placement="top">
                                                    <Option value="身份证">身份证</Option>
                                                    <Option value="户口本">户口本</Option>
                                                    <Option value="护照">护照</Option>
                                                    <Option value="军官证">军官证</Option>
                                                    <Option value="港澳居民来往内地通行证">港澳居民来往内地通行证 </Option>
                                                    <Option value="其他">其他</Option>
                                                </Select>  
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6" v-if="insuredForm.insured_id_type == '身份证'">
                                            <FormItem prop="insured_id_number"   label="证件号码" key="id_number_input">
                                                <Input  @on-change="idCardInsuredChange($event,insuredForm,index)"   placeholder="请输入证件号码" v-model="insuredForm.insured_id_number"></Input>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6" v-else>
                                            <FormItem prop="insured_id_number" :rules="{required: true, message: '请填写证件号', trigger: 'blur'}"  label="证件号码" key="no_id_number" >
                                                <Input    placeholder="请输入证件号码" v-model="insuredForm.insured_id_number"></Input>   
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="insured_sex" label="性别">
                                                <Select   placeholder="请输入性别" v-model="insuredForm.insured_sex">
                                                    <Option value="1">男</Option>
                                                    <Option value="2">女</Option>
                                                </Select>   
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="birthdaytime" label="出生日期">
                                                <DatePicker  type="date" @on-change="datachange($event,insuredForm,'insured_birthday')" v-model="insuredForm.insured_birthdaytime" placeholder="请填写出生日期" :transfer=true placement="top"></DatePicker>  
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="12">
                                        <FormItem prop="id_effect_datetime" label="证件有效期">
                                             <DatePicker  class="common-form-body-left"  type="date" @on-change="datachange($event,insuredForm,'id_effect_date')" v-model="insuredForm.id_effect_datetime" placeholder="请输入证件有效期" :transfer=true placement="top"></DatePicker><Checkbox true-value="1" false-value="0" class="common-form-body-right checkbox" v-model="insuredForm.id_effect_long">长期有效</Checkbox>  
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="marital" label="婚姻">
                                            <Select :transfer=true  placeholder="请选择" v-model="insuredForm.marital">
                                                <Option value="">请选择婚姻状况</Option>
                                                <Option value="已婚">已婚</Option>
                                                <Option value="未婚">未婚</Option>
                                                <Option value="已婚有子女">已婚有子女</Option>
                                                <Option value="离异">离异</Option>
                                                <Option value="丧偶">丧偶</Option>
                                            </Select>   
                                        </FormItem>
                                    </Col>  
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="nationality" label="国籍">
                                            <Input    placeholder="请输入" v-model="insuredForm.nationality"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="education" label="学历">
                                            <Select :transfer=true  placeholder="请选择" v-model="insuredForm.education">
                                                <Option value="">请选择学历</Option>
                                                <Option value="大专">大专</Option>
                                                <Option value="本科">本科</Option>
                                                <Option value="研究生及以上">研究生及以上</Option>
                                                <Option value="中专">中专</Option>
                                                <Option value="高中">高中</Option>
                                                <Option value="初中">初中</Option>
                                                <Option value="小学">小学</Option>
                                                <Option value="学龄前">学龄前</Option>
                                            </Select>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="height" label="身高(cm)">
                                            <Input    placeholder="请输入" v-model="insuredForm.height"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="weight" label="体重(kg)">
                                            <Input    placeholder="请输入" v-model="insuredForm.weight"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="insured_mobile" label="联系电话">
                                            <Input    placeholder="请导入联系电话" v-model="insuredForm.insured_mobile"></Input>   
                                        </FormItem>
                                    </Col>
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="com_name" label="工作单位">
                                            <Input  type="text" v-model="insuredForm.com_name"  placeholder="请导入工作单位"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="profession" label="职业/工种">
                                            <Input  type="text" v-model="insuredForm.profession" placeholder="请导入职业/工种"></Input>   
                                        </FormItem>
                                    </Col>                                      
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="postcode" label="邮编">
                                            <Input  type="text" v-model="insuredForm.postcode" placeholder="请导入邮编"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="8" :lg="6">
                                        <FormItem prop="email" label="Email">
                                            <Input  type="text" v-model="insuredForm.email"  placeholder="请导入Email"></Input>   
                                        </FormItem>
                                    </Col> 
                                    <Col :xs="24" :sm="24" :md="12" :lg="12">
                                        <FormItem prop="home_address" label="详细地址">
                                            <Input class="common-form-body-left"  type="text" v-model="insuredForm.home_address" placeholder="请导入详细地址"></Input><Checkbox true-value="1" @on-change="asApplationChange($event)" false-value="0" class="common-form-body-right checkbox" v-model="asApplation">同投保人地址</Checkbox>     
                                        </FormItem>
                                    </Col>  
                                </Row>
                            </Form>
                            <Row>
                                <Col span="2" offset="21">
                                    <Button type="primary" @click="insuredToList" shape="circle" long>确定</Button>
                                </Col>                                
                            </Row>
                            <div class="mt20">
                                <Table stripe border :columns="insuredTable" :data="insuredList"></Table>
                            </div>
                        </div>
                    </TabPane>
                    <TabPane label="险种列表" name="proList">
                        <div class="common-box-header mt20">
                            <h3>险种列表</h3>                                                          
                            <!-- <Button class="fr mt7 ml5" @click="open_party_modal" type="warning" icon="icon iconfont icon-addOnly">新增险种</Button> -->
                        </div>
                        <div class="common-box-body common-form-body ">
                            
                                <!-- <div class="insured-box-title">
                                    险种信息（{{index + 1}}）
                                    <span class="insured-box-title-right" @click="delProItem(index)"><Icon class="insured-box-title-right-i" type="close-circled"></Icon>删除</span>
                                </div> -->
                                <Form ref="proList" :model="proList" :rules="insurances_ruleValidate">
                                    <Row>                                   
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem label="主附险类型" prop="is_main">
                                                <Select  v-model="proList.is_main" @on-change="is_main_change($event)"  placeholder="请选择">
                                                    <Option value="1">主险</Option>
                                                    <Option value="2">附加险</Option>                                
                                                </Select>    
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="16" :lg="12">
                                            <FormItem  label="险种名称" prop="name">
                                                <Input disabled class="common-form-body-left" type="text" v-model="proList.name"  placeholder="请导入险种"></Input><Button class="common-form-body-right" @click="openProModal()"  type="warning" icon="icon iconfont icon-daoru">导入</Button>  
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem label="被保人" prop="insured_name">
                                                <Select :transfer=true v-model="proList.insured_name" @on-change="insuredChange($event)"  placeholder="请选择">
                                                    <Option :value="index+'-'+item.insured_name" v-for="(item,index) in insuredList" :key="index">{{item.insured_name}}</Option>                              
                                                </Select>    
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem label="保险金额" prop="amount">
                                                <Input type="text" v-model="proList.amount" placeholder="请输入保险金额"></Input>   
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem  label="保险期间" prop="period">
                                                <Select :transfer=true v-model="proList.period"  placeholder="请选择">
                                                    <Option v-for="(sitem, index) in proList.periodarry" :value="sitem" :key="sitem">{{sitem}}</Option>
                                                </Select>  
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem label="交费期间" prop="pay_period"> 
                                                <Select :transfer=true v-model="proList.pay_period" placeholder="请选择">
                                                    <Option v-for="(sitem, index) in proList.pay_periodarry" :value="sitem" :key="sitem">{{sitem}}</Option>
                                                </Select>  
                                            </FormItem> 
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem  label="承保年龄" prop="limit_age">
                                                <Select :transfer=true ref="period" v-model="proList.limit_age"  placeholder="请选择">
                                                    <Option v-for="(sitem, index) in proList.agearry" :value="sitem.value" :key="sitem.value">{{sitem.label}}</Option>
                                                </Select>  
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem label="保费" prop="premium">
                                                <Input type="text" v-model="proList.premium" placeholder="请输入保费"></Input>   
                                            </FormItem>
                                        </Col>
                                                                                 
                                    </Row>   
                                </Form>
                                <Row>
                                    <Col span="2" offset="21">
                                        <Button type="primary" @click="proToList" shape="circle" long>确定</Button>
                                    </Col>                                
                                </Row>
                                <div class="mt20">
                                    <Table stripe border :columns="proTable" :data="proTableList"></Table>
                                </div>
                        </div>
                    </TabPane>
                    <TabPane label="受益人" name="benefit">
                        <div class="common-box-header mt20">
                            <h3>受益人</h3>
                            <div class="fr">
                                受益方式：
                                <RadioGroup v-model="beneficiary_type"  @on-change="benefit_change($event)">
                                    <Radio label="指定受益"></Radio>
                                    <Radio label="法定受益"></Radio>                                            
                                </RadioGroup>  
                            </div>                           
                            <!-- <Button @click="importbenfit()"  :disabled="benefitTag" class="fr mt7" type="warning" icon="icon iconfont icon-daoru">新增受益人</Button>                         -->
                        </div>
                        <div class="common-box-body common-form-body ">
                            <div class="insured_box">
                                <Form ref="benefitForm" :model="benefitForm" :rules="benefit_ruleValidate">
                                    <Row>                                   
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem  label="与投保人关系">
                                                <Select :disabled="readonly" v-model="benefitForm.relation" @on-change="benefitreChange($event)" placeholder="请选择" :transfer=true placement="top">
                                                    <Option value="本人">本人</Option>
                                                    <Option value="配偶">配偶</Option>
                                                    <Option value="父母">父母</Option>
                                                    <Option value="子女">子女</Option>
                                                    <Option value="兄弟姐妹">兄弟姐妹</Option>
                                                    <Option value="其他">其他</Option>
                                                </Select>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="name" label="受益人">
                                                <Input :disabled="readonly" class="common-form-body-left" type="text" v-model="benefitForm.name"  placeholder="请导入受益人"></Input><Button :disabled="hasagent" class="common-form-body-right" @click="importapplicant(3)"  type="warning" icon="icon iconfont icon-daoru">导入</Button>  
                                            </FormItem>
                                        </Col>
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem  label="证件类型">
                                                <Select :disabled="readonly" @on-change="benefitTypeChange($event)"  placeholder="请选择证件类型" v-model="benefitForm.id_type" :transfer=true placement="top">
                                                    <Option value="身份证">身份证</Option>
                                                    <Option value="户口本">户口本</Option>
                                                    <Option value="护照">护照</Option>
                                                    <Option value="军官证">军官证</Option>
                                                    <Option value="港澳居民来往内地通行证">港澳居民来往内地通行证 </Option>
                                                    <Option value="其他">其他</Option>
                                                </Select>  
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6" v-if="benefitForm.id_type == '身份证'">
                                            <FormItem prop="id_number"   label="证件号码" key="id_number_input">
                                                <Input :disabled="readonly" @on-change="benefitIdChange($event)"  placeholder="请输入证件号码" v-model="benefitForm.id_number"></Input>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6" v-else>
                                            <FormItem  prop="id_number" :rules="{required: true, message: '请填写证件号', trigger: 'blur'}" label="证件号码" key="no_id_number" >
                                                <Input  :disabled="readonly"   placeholder="请导入证件号码" v-model="benefitForm.id_number"></Input>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem  label="性别">
                                                <Select :disabled="readonly" :transfer=true placement="top"  placeholder="请输入性别" v-model="benefitForm.sex">
                                                    <Option value="1">男</Option>
                                                    <Option value="2">女</Option>
                                                </Select>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="mobile" label="手机号码">
                                                <Input  :disabled="readonly"  placeholder="请输入手机号码" v-model="benefitForm.mobile"></Input>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem label="受益顺序">
                                                <Select :disabled="readonly" :transfer=true placement="top"  placeholder="请选择受益顺序" v-model="benefitForm.order">
                                                    <Option value="1">1</Option>
                                                    <Option value="2">2</Option>
                                                    <Option value="3">3</Option>
                                                    <Option value="4">4</Option>
                                                    <Option value="5">5</Option>
                                                </Select>   
                                            </FormItem>
                                        </Col> 
                                        <Col :xs="24" :sm="24" :md="8" :lg="6">
                                            <FormItem prop="scale"  label="受益比例">
                                                <Input  :disabled="readonly"  placeholder="请输入收益比例" v-model="benefitForm.scale"></Input>   
                                            </FormItem>
                                        </Col> 
                                    </Row>
                                </Form>
                                <Row>
                                    <Col span="2" offset="21">
                                        <Button type="primary" :disabled="readonly" @click="benefitToList" shape="circle" long>确定</Button>
                                    </Col>                                
                                </Row>
                                <div class="mt20">
                                    <Table stripe border :columns="benefitTable" :data="benefitdata"></Table>
                                </div>
                            </div>
                        </div>
                    </TabPane>
                </Tabs>
            </div>
            <div :class="slidetoggle?'fixed-bottom':'fixed-bottom sidehide' ">
                <Button type="primary" v-if="$isShow('policy/create')" @click="sendpolicy" shape="circle" icon="icon iconfont icon-dui">提交保单信息</Button>
                <Button type="primary" @click="cancelpolicy" class="ml20 reset" shape="circle" icon="icon iconfont icon-tableresetpassword">返回</Button>
            </div> 
        </div>
        
        <Modal v-model="importEntering" :mask-closable='closeable' width="860" title="导入录单员信息" :loading="loading">
            <div class="modal-body">            
                <Row>
                    <Col span="24">
                        <div class="import-left">
                            <div class="common-box-body">
                                <div class="import-search">
                                    <Form ref="formInline">
                                        <Form-item label="姓名">
                                            <Input placeholder="请输入姓名" v-model="searchEntering">
                                                <Button slot="append" @click="getEntering(true)" type="primary" icon="icon iconfont icon-sousuo"></Button>
                                            </Input>
                                        </Form-item> 
                                    </Form>
                                </div> 
                                <div class="import-list">
                                    <Table :loading="tableloading" :show-header=false stripe height="415" :columns="columnsEntering" :data="enteringList"></Table>
                                </div>                             
                            </div>
                            <div style="overflow:hidden;margin:20px;">
                                <Page ref="enterPage" :total="enterTotal" :current.sync="enterCurrent" show-total @on-change="enterPageChange"></Page>
                            </div>  
                        </div> 
                    </Col>
                </Row> 
            </div>                      
            <div slot="footer"></div>          
        </Modal>
        <!-- 导入投保人弹框 -->
        <Modal v-model="importcustomer" :mask-closable='closeable' width="860" title="导入投保人" @on-ok="surebtn" :loading="loading">
            <div class="modal-body">            
                <Row>
                    <Col span="24">
                        <div class="import-left">
                            <div class="common-box-body">
                                <div class="import-search">
                                    <Form ref="formInline" >
                                        <Row>
                                            <Col span="6">
                                                <Form-item>
                                                    <Input v-model="customerForm.name" placeholder="请输入姓名">
                                                        <!-- <Button @click="getcustomer(1)" slot="append" type="primary" icon="icon iconfont icon-sousuo"></Button> -->
                                                    </Input>
                                                </Form-item> 
                                            </Col>
                                            <Col span="6">
                                                <Form-item>
                                                    <Select :transfer=true  placeholder="请选择性别" v-model="customerForm.sex">
                                                        <Option value="">全部</Option>
                                                        <Option value="1">男</Option>
                                                        <Option value="2">女</Option>
                                                    </Select>
                                                </Form-item>  
                                            </Col>
                                            <Col span="6">
                                                <Form-item>
                                                    <Input v-model="customerForm.mobile" placeholder="请输入手机号">
                                                        <!-- <Button @click="getcustomer(1)" slot="append" type="primary" icon="icon iconfont icon-sousuo"></Button> -->
                                                    </Input>
                                                </Form-item> 
                                            </Col>
                                            <Col span="6">
                                                <Button @click="getcustomer(1)"  type="primary" shape="circle" icon="icon iconfont icon-sousuo">搜索</Button>
                                            </Col>
                                        </Row>
                                        
                                    </Form>
                                </div> 
                                <div class="import-list table-theme">
                                    <Table :loading="tableloading" ref="currentRowTable" @on-current-change="tableCurrentChange($event)" size="large" stripe highlight-row border  height="455" :columns="columnsuser" :data="appCustomerList"></Table>
                                </div>                                                          
                            </div>
                            <div style="overflow:hidden;margin:20px;">
                                <Page :total="apptotal" :current="customerForm.page" show-total @on-change="pageChange"></Page>
                            </div>  
                        </div> 
                    </Col>
                </Row> 
            </div>                      
            <div slot="footer" class="slot-footer">  
                <!-- <Button type="ghost" size="large" @click="cancel" class="fr ml10 bgfff">取消</Button>             
                <Button type="primary"  size="large" @click="importapp" :disabled="hasctmid" class="fr ">确定</Button>    -->
            </div>            
        </Modal>
        <!-- 选择险种弹框 -->
        <Modal v-model="importPro" :mask-closable='closeable' width="860" title="选择险种" :loading="loading">
            <div class="modal-body">            
                <Row>
                    <Col span="24">
                        <div class="import-left">
                            <div class="common-box-body">
                                <div class="import-search">
                                    <Form ref="formInline" >
                                        <Form-item label="险种名称">
                                            <Input v-model="searchpro" placeholder="请输入险种名称">
                                                <Button @click="getSearchPro()" slot="append" type="primary" icon="icon iconfont icon-sousuo"></Button>
                                            </Input>
                                        </Form-item> 
                                    </Form>
                                </div> 
                                <div class="import-list table-theme">
                                    <Table :loading="tableloading"   @on-current-change="tableProCurrentChange($event)" size="large" stripe highlight-row border  :columns="columnspro" :data="searchProList"></Table>
                                </div>                                                          
                            </div>
                            <div style="overflow:hidden;margin:20px;">
                                <Page :total="prototal" :current="nowPage" :page-size="proPageSize"  @on-change="proPageChange" @on-page-size-change="proPageSizeChange"  show-total ></Page>
                            </div>  
                        </div> 
                    </Col>
                </Row> 
            </div>                      
            <div slot="footer" class="slot-footer">  
                <!-- <Button type="ghost" size="large" @click="cancel" class="fr ml10 bgfff">取消</Button>             
                <Button type="primary"  size="large" @click="importProBtn" :disabled="hasctmid" class="fr ">确定</Button>    -->
            </div>            
        </Modal>
        <Modal v-model="party_modal" :mask-closable='closeable' width="860" title="导入关系人" @on-ok="surebtn" :loading="loading">
            <Row class="party-box">
                <Col span="24">
                    <div class="import-left">
                        <div class="common-box-body">
                            <div class="import-search">
                                <Form ref="formInline" >
                                    <Form-item label="姓名">
                                        <Input v-model="searchcustom" placeholder="请输入姓名">
                                            <Button @click="getcustomer(1)" slot="append" type="primary" icon="icon iconfont icon-sousuo"></Button>
                                        </Input>
                                    </Form-item> 
                                </Form>
                            </div> 
                            <div class="import-list table-theme">
                                <Table :loading="tableloading" stripe highlight-row border @on-current-change="tableFirendCurrentChange($event)" size="large" :columns="partytable" :data="firendlist"></Table>
                            </div>                                                          
                        </div>
                        <div style="overflow:hidden;margin:20px;">
                            <Page :total="firendtotal" show-total @on-change="pageFirendChange"></Page>
                        </div>  
                    </div>
                </Col>
            </Row>    
            <div slot="footer" class="slot-footer">  
                <!-- <Button type="ghost" size="large" @click="cancel_party" class="fr ml10 bgfff">取消</Button>             
                <Button type="primary"   size="large" @click="import_party" :disabled="firendTag" class="fr ">确定</Button>    -->
            </div>  
        </Modal>
        <Modal v-model="pay_periodModal" title="选择交费期间" width="800">
            <Row>
                <RadioGroup v-model="policyform.pay_period" @on-change="pay_periodModalChange">
                    <Col span="4" v-for="item in allPay_period" :key="item" style="margin-bottom:10px">
                        <Radio :label="item" ></Radio>
                    </Col>
                </RadioGroup>
            </Row>
            <div slot="footer">       
            </div>
        </Modal>
        <Modal v-model="periodModal" title="选择保险期间" width="800" >
            <Row>
                <RadioGroup v-model="policyform.period" @on-change="periodModalChange">
                    <Col span="4" v-for="item in allPeriod" :key="item" style="margin-bottom:10px">
                        <Radio :label="item" ></Radio>
                    </Col>
                </RadioGroup>
            </Row>
            <div slot="footer">   
            </div>
        </Modal>  
        <Spin size="large" fix v-if="spinShow"></Spin>     
    </div>
</template>

<script>
import productTitle from '../../components/productTitle'
import { getInfo } from '../../api/common'
import { formatTime } from '../../libs/time'
import { getByName , getById} from '../../api/employee'
import { AgentByName } from '../../api/customer'
import { proGetByName , get_pay_period , get_period } from '../../api/product_v2' 
import {  getListByCompany, getDetailByIdProduct } from '../../api/product'
import { parteGetByName } from '../../api/parter'
import { policyCreate_v2 , getEmployee , getApplicant} from '../../api/policy'
import { getListByName } from '../../api/yun_org' 
import { getByNameCustomer , createCustomer , getDetailById , updateCustomer , getFriend } from '../../api/yun_customer'
import util from '../../libs/util'
import { checkIdCard } from '../../libs/validate'
export default {
    data() {
        const idCard = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('身份证号不能为空'));
            } else {
                if (checkIdCard(value)) {
                    callback();                    
                }else{
                    callback(new Error('身份证号码不正确'));
                }
                
            }
        }; 
        return {
            readonly:false,
            ageTag:true,
            asApplation:'0',
            tabName:'name',
            benefitTable:[
                {
                    title: '姓名',
                    key: 'name',
                    align:"center",
                },
                {
                    title: '证件号码',
                    key: 'id_number',
                    align:"center",
                },
                {
                    title: '关系',
                    key: 'relation',
                    align:"center",
                },
                {
                    title: '受益顺序',
                    key: 'order',
                    align:"center",
                },
                {
                    title: '收益比例',
                    key: 'scale',
                    align:"center",
                },
                {
                    title: '操作',
                    align:"center",
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'error',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {           
                                        this.benefitdata.splice(params.index,1)
                                    }
                                }
                            }, '删除'),
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.editbenefitlist(params.index)
                                    }
                                }
                            }, '编辑')
                        ]);
                    }
                },
            ],
            benefitdata:[
                
            ],
            benefitBase:{
                id_type:'身份证'
            },
            benefitForm:{
                id_type:'身份证'
            },
            proListBase:{
                
            },
            proList:{
                agearry:[]
            },
            proTable:[
                {
                    title: '主附险类型',
                    key: 'is_main',
                    align:"center",
                    render:(h,params)=>{
                        return h('div',{

                        },params.row.is_main == 1 ? '主险' : '附加险')
                    }
                },
                {
                    title: '险种名称',
                    key: 'name',
                    align:"center",
                },
                {
                    title: '被保人',
                    key: 'insured_name',
                    align:"center",
                },
                {
                    title: '承保年龄',
                    key: 'limit_age',
                    align:"center",
                    render:(h,params)=>{
                        return h('div',{

                        },params.row.limit_age+'岁')
                    }
                },
                {
                    title: '交费期间',
                    key: 'pay_period',
                    align:"center",
                },
                {
                    title: '保险期间',
                    key: 'period',
                    align:"center",
                },
                {
                    title: '保费',
                    key: 'premium',
                    align:"center",
                },
                {
                    title: '保额',
                    key: 'amount',
                    align:"center",
                },
                {
                    title: '操作',
                    align:"center",
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'error',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {           
                                        this.proTableList.splice(params.index,1)
                                    }
                                }
                            }, '删除'),
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.edit_pro(params.index)
                                    }
                                }
                            }, '编辑')
                        ]);
                    }
                },
            ],
            proTableList:[],
            importAppType:'',
            insuredTable:[
                {
                    title: '姓名',
                    key: 'insured_name',
                    align:'center'
                },
                {
                    title: '性别',
                    key: 'insured_sex',
                    align:'center',
                    render:(h,params)=>{
                        return h('div',{

                        },params.row.insured_sex == 1 ? '男' :(params.row.insured_sex == 2 ? '女': ''))
                    }
                },
                {
                    title: '出生日期',
                    key: 'insured_birthday',
                    align:'center'
                },
                {
                    title: '与投保人关系',
                    key: 'insured_relation',
                    align:'center'
                },
                {
                    title: '证件号码',
                    key: 'insured_id_number',
                    align:'center'
                },
                {
                    title: '联系电话',
                    key: 'insured_mobile',
                    align:'center'
                },
                {
                    title: '操作',
                    align:'center',
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'error',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {           
                                        this.removeInsured(params.index)                                       
                                    }
                                }
                            }, '删除'),
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.editInsured(params.index)
                                    }
                                }
                            }, '编辑')
                        ]);
                    }
                },
            ],
            insuredList:[],
            customerForm:{
                name:'',
                sex:'',
                mobile:'',
                page:1
            },
            isOffice:true,
            location:1,
            enteringPage:1,
            searchEntering:'',
            enterCurrent:1,
            enterTotal:0,
            importEntering:false,
            columnsEntering:[
                {
                    title: '姓名',
                    key: 'name'
                },
                {
                    title: '工号',
                    key: 'job_code',
                    render: (h, params) => {
                        return h('div', {},'工号：'+params.row.job_code);
                    }
                },
                {
                    title: '操作',
                    key: 'address',
                    width:100,
                    align:"center",
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small',
                                },                               
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.importEmp(params.index);
                                        this.searchemploy="";
                                        this.emplist=[];
                                    }
                                }
                            }, '导入')
                        ]);
                    }
                }
            ],
            enteringList:[],
            insuredFormBase:{
                insured_id_type:'身份证'
            },
            insuredFormBase:{
                insured_id_type:'身份证',
                nationality:'',
                education:'',
                height:'',
                weight:'',
                marital:'',
                id_effect_date:'',
                id_effect_datetime:'',
                id_effect_long:'0'
            },
            insuredForm :{
                insured_id_type:'身份证',
                nationality:'',
                education:'',
                height:'',
                weight:'',
                marital:'',
                id_effect_date:'',
                id_effect_datetime:'',
                id_effect_long:'0'
            },
            importTag:true,
            benefitTag:false,
            allPay_period:[],
            allPeriod:[],
            baseBenefit:{
                id_number:'',
                id_type:'身份证',
                mobile:'',
                name:'',
                order:'',
                relation:'',
                scale:'',
                sex:''
            },
            beneficiaries:[
                {
                    id_number:'',
                    id_type:'身份证',
                    mobile:'',
                    name:'',
                    order:'',
                    relation:'',
                    scale:'',
                    sex:''
                }
            ],
            friendType : '',
            firendIndex : 0, 
            firendtotal:0,
            firendTag:true,
            hasctmid:true,
            prototal:0,
            proPage:1,
            nowPage:1,
            proPageSize:10,            
            mainTag:0,
            proArrayTag:0,
            importPro:false,
            periodModal:false,
            pay_periodModal:false,
            pay_periodRadio:'',
            periodRadio:'',
            orglist:[],
            options3:{
                disabledDate(date){
                    return date && date.valueOf() > Date.now() ;
                }
            },
            apptotal:0,
            apppage:1,
            applicant_number:true,
            idrule:{
                 required: true, pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: '请填写证件号', trigger: 'blur' 
            },
            party_modal:false,
            pay_period_disable:true,
            insured_customer_id:'',
            
            insurances:{
                type:'保险金额',
                pay_periodarry:[],
                periodarry:[],
                pay_period:'',
                period:'',
            },
            insured:{
                insured_name:'',
                name:'',
                id_type:'身份证'
            },
            importpro:false,
            customer:{
                id_type:'身份证'
            },
            customerEdit:true,
            pro_index_tag:0,
            create_or_update:0,
            currentRow:{},
            importbenefit:false,
            tableloading:false,
            spinShow:false,
            addcustomer:false,


            importcustomer:false,

            
            importemployee:false,
            importtype:'',
            canedit:true,
            re_canedit:true,
            closeable:false,
            loading:true,
            proloading:false,
            options1:[],
            comoptions:[],
            renewalInsure:{},
            searchemploy:'',
            searchcustom:'',
            searchpro:'',
            beneficiary_type:'指定受益',
            firendlist:[],
            commonlist:[],
            //录单员
            entering:{
                job_code:'',
                name:'',
                datetime:formatTime(new Date(),'yyyy-MM-dd'),
                date:formatTime(new Date(),'yyyy-MM-dd')
            },
            //业务员
            agent:{
                oid:'',
                oname:'',
                dept_id:'',
                dept_name:'',
                rank_id:'',
                rank_name:'',
                name:'',
                eid :'',
                job_code:'',
                leader_name:'',
                leader_id :'',
                rec_name:'',
                rec_id:''
            },
            //保单信息
            policyform:{
                yun_org_mid:'',
                policy_type:'个人保险单',
                cid:'',
                cname:'',
                name:'',
                insure_num:'',
                policy_num:'',
                pay_type:'',
                premium:'',
                is_short:'2',
                insure_date:formatTime(new Date(),'yyyy-MM-dd'),
                insure_datetime:formatTime(new Date(),'yyyy-MM-dd'),
                underwrite_datetime:'',
                underwrite_date:'',
                effect_datetime:'',
                effect_date:'',
                receipt_datetime:'',
                receipt_date:'',
                visit_datetime:'',
                visit_date:'',
                withdraw_datetime:'',
                withdraw_date:'',
                terminal_datetime:'',
                terminal_date:'',
                settlement_datetime:'',
                settlement_date:'',
                status:'1'
            },
            //投保人信息
            applicant:{
                customer_id:'',
                name:'',
                id_type:'身份证',
                id_number:'',
                mobile:'',
                sex:'',
                birthday:'',
                birthdaytime:'',
                com_name:'',
                profession:'',
                postcode:'',
                email:'',
                nationality:'',
                education:'',
                height:'',
                weight:'',
                marital:'',
                id_effect_date:'',
                id_effect_datetime:'',
                id_effect_long:'0'
            },
            benefit:{

            },
            //险种列表
            insurancesArray:[
                {
                    name:'',
                    pay_periodarry:[],
                    periodarry:[],
                    agearry:[],
                    pay_period:'',
                    period:'',
                    insured_id_type:'身份证'
                },
            ],
            insurancesItem:{
                name:'',
                pay_periodarry:[],
                periodarry:[],
                agearry:[],
                pay_period:'',
                period:'',
                insured_id_type:'身份证'
            },
            //被保人
            policyDetail:{
                insureds:[
                    {
                        relation:'本人',
                        canedit:true,
                        name:'',
                        id_type:'身份证',
                        id_number:'',
                        mobile:'',
                        sex:'',
                        birthday:'',
                        birthdaytime:'',
                        com_name:'',
                        profession:'',
                        insurances:[
                            {
                                mongo_id:'',
                                name:'',
                                period:'',
                                period_arry:[],
                                pay_period:'',
                                pay_period_arry:[],
                                premium:'', 
                                type:'保险金额',
                                amount :''
                            }
                        ],
                        beneficiary_type:'指定受益',
                        beneficiary:[
                            {
                                name:'',
                                id_type:'身份证',
                                id_number:'',
                                mobile:'',
                                relation:'',
                                sex:'',
                                birthday:'',
                                birthdaytime:'',
                                order:'',
                                scale:''
                            }
                        ]
                    }
                ]
            },

            prodata:[],
            partytable:[
                {
                    title: '姓名',
                    key: 'name',
                    align:"center",
                },
                {
                    title: '证件号码',
                    key: 'id_number',
                    align:"center",
                },
                {
                    title: '关系',
                    key: 'relation',
                    align:"center",
                },
            ],
            partydata:[],
            columns: [
                {
                    title: '姓名',
                    key: 'name'
                },
                {
                    title: '工号',
                    key: 'job_code',
                    render: (h, params) => {
                        return h('div', {},'工号：'+params.row.job_code);
                    }
                },
                {
                    title: '操作',
                    key: 'address',
                    width:100,
                    align:"center",
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small',
                                },                               
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.impempbtn(params.row.id);
                                        this.searchemploy="";
                                        this.emplist=[];
                                    }
                                }
                            }, '导入')
                        ]);
                    }
                }
            ],
            columnspro:[
                {
                    title: '险种名称',
                    key: 'name',
                    algin:'center'
                },
                {
                    title: '承保年龄',
                    key: 'limit_age',
                    algin:'center'
                },
                {
                    title: '交费期间',
                    key: 'pay_period',
                    algin:'center',
                    render:(h,params)=>{
                        return h('div',{},params.row.pay_period.join('/'))
                    }
                },    
                {
                    title: '保险期间',
                    key: 'period',
                    algin:'center',
                    render:(h,params)=>{
                        return h('div',{},params.row.period.join('/'))
                    }
                },    
            ],
            searchProList:[],
            columnsuser:[
                {
                    title: '姓名',
                    key: 'name',
                    algin:'center'
                },
                {
                    title: '性别',
                    key: 'sex',
                    algin:'center',
                    render:(h,params)=>{
                        return h('div',{

                        } ,params.row.sex == 1 ? '男' :(params.row.sex == 2 ? '女': ''))
                    }
                },
                {
                    title: '证件类型',
                    key: 'id_type',
                    algin:'center'
                },
                {
                    title: '证件号码',
                    key: 'id_number',
                    algin:'center'
                },    
                {
                    title: '手机号码',
                    key: 'mobile',
                    algin:'center',
                    render:(h,params)=>{
                        return params.row.mobile ? params.row.mobile : '暂无'
                    }
                },    
            ],
            columnsrelation:[
                {
                    title: '姓名',
                    key: 'name',
                    width:100,
                    algin:'center'
                },
                {
                    title: '证件号码',
                    key: 'id_number',
                    algin:'center'
                },      
            ],
            appCustomerList:[
                
            ],
            emplist:[

            ],
            insurances_ruleValidate:{
                insured_id:[
                    {required: true, message: '被保人不能为空', trigger: 'blur'}  
                ],
                is_main:[
                    {required: true, message: '主附险不能为空', trigger: 'change'}     
                ],
                name:[
                    {required: true, message: '险种名称不能为空', trigger: 'change'}        
                ],
                limit_age:[
                    { required: true, type:'number',transform(value) {
                        return parseInt(value);
                    },default:0, message: '请选择投保年龄', trigger: 'change' }
                ],
                period:[
                     {required: true, message: '请选择保险期间', trigger: 'change'}        
                ],
                pay_period:[
                     { required: true, message: '请填写交费期间', trigger: 'change' }
                ],
                premium: [
                    { required: true,  pattern:/^(\d|[1-9]\d+)(\.\d+)?$/, message: '请正确填写保费', trigger: 'blur' }
                ],
                amount: [
                    { required: true, pattern:/^(\d|[1-9]\d+)(\.\d+)?$/,message: '请正确填写保额', trigger: 'blur,change' }
                ],
                insured_name:[
                     {required: true, message: '被保人不能为空', trigger: 'blur'},
                     {trigger: 'change'}  
                ]
                
            },
            insured_rule:{
                insured_name: [
                    { required: true, message: '请输入姓名', trigger: 'blur',pattern:/^[\u4e00-\u9fa5A-Za-z0-9]{0,50}$/ }
                ],
                insured_relation: [
                    { message: '请选择与投保人关系', trigger: 'change' }
                ],
                insured_id_type: [
                    {  message: '请选择证件类型', trigger: 'change' }
                ],
                insured_id_number: [
                    { required: true, 
                    pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, 
                    message: '请填写证件号', trigger: 'blur' },
                ],
                insured_other_id_number:[
                    { required: true,  message: '请填写证件号', trigger: 'blur' },
                ],
                insured_sex: [
                    { message: '请选择性别', trigger: 'change' }
                ],
                insured_mobile:[
                    {  required: true, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请正确填写手机号', trigger: 'blur,change' }
                ],
            },
            entering_ruleValidate: {
                job_code:[
                    {  message: '请填写录单员工号', trigger: 'change' }
                ],
                name: [
                    {  message: '请填写录单员姓名', trigger: 'change' }
                ],  
                datetime: [
                    {  type: 'date', message: '请选择录单时间', trigger: 'change' }
                ],              
            },
            agent_ruleValidate: {
                // oname:[
                //     { required: true, message: '请选择机构', trigger: 'change' }
                // ],
                // dept_name: [
                //     { required: true, message: '请选择部门', trigger: 'change' }
                // ],
                // rank_name : [
                //     { required: true, message: '请选择职级', trigger: 'change' }
                // ], 
                job_code  : [
                    { required: true, message: '请选择工号', trigger: 'change' }
                ], 
                name: [
                    { required: true, message: '请选择姓名', trigger: 'change' }
                ],
            },
            policy_ruleValidate:{
                yun_org_mid:[
                     { required: true, message: '请选择归属机构', trigger: 'change' }
                ],
                cid:[
                    { required: true, message: '请填写保险公司',transform(value) {
                    return value.toString();
                    }, trigger: 'change' }
                ],
                insure_datetime:[
                    {  type:'date', message: '请填写投保时间', trigger: 'change' }
                ],
                name: [
                    {  message: '请填写保险计划', trigger: 'blur' }
                ],
                insure_num: [
                    { message: '请填写投保单号', trigger: 'blur',pattern:/^[0-9a-zA-Z]+$/  }
                ], 
                policy_num: [
                    {  message: '请填写保单号', trigger: 'blur',pattern:/^[0-9a-zA-Z]+$/ }
                ], 
                pay_period: [
                    { required: true, message: '请选择交费期间', trigger: 'change' }
                ], 
                period: [
                    { required: true, message: '请选择保险期间', trigger: 'change' }
                ], 
                pay_type: [
                    { message: '请填写交费方式', trigger: 'change' }
                ], 
                premium: [
                    { required: true, pattern:/^(\d|[1-9]\d+)(\.\d+)?$/, message: '请正确填写保费', trigger: 'blur' }
                ],
                status:[
                    { required: true, message: '请选择保单状态', trigger: 'change' }
                ],
            },
            applicant_ruleValidate:{
                name:[
                    { required: true, message: '投保人姓名不能为空！', trigger: 'blur,change'}
                ],
                id_type: [
                    {  message: '请选择证件类型', trigger: 'change' }
                ],
                id_number: [
                    { required: true, pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: '请正确填写证件号', trigger: 'blur' }
                ], 
                mobile: [
                    { required: true, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请正确填写手机号', trigger: 'blur' }
                ],  
                sex: [
                    {  message: '请选择性别', trigger: 'change' }
                ],
                // birthdaytime: [
                //     {  type:'date', message: '请选择日期', trigger: 'blur,change' }
                // ],
                postcode:[
                    { pattern: /^[0-9]{6}$/, message: '请正确填写邮编', trigger: 'blur' }
                ],
                email: [
                    { type:'email', message: '请正确填写email', trigger: 'blur' }
                ],
            },
            customer_ruleValidate:{
                name:[
                    { required: true, message: '请填写姓名', trigger: 'blur' }
                ],
                id_type: [
                    { required: true, message: '请选择证件类型', trigger: 'change' }
                ],
                sex: [
                    { required: true, message: '请选择性别', trigger: 'change' }
                ],
                birthdaytime: [
                    { required: true, type:'date', message: '请选择日期', trigger: 'change' }
                ],
            },
            benefit_ruleValidate:{
                name:[
                     { required: true, message: '请填写姓名', trigger: 'blur' }
                ],
                id_number: [
                    { required: true, pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: '请正确填写证件号码', trigger: 'blur' },
                ],
                mobile: [
                    { required: true, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请正确填写手机号', trigger: 'blur' }
                ],
                scale: [
                    { pattern: /^(([1-9]\d?)|100)$/, message: '请正确填写受益比例', trigger: 'blur' }
                ]
            }
            // insured_ruleValidate:{  
            //     name:[
            //         { required: true, message: '请填写姓名', trigger: 'blur' }
            //     ],
            //     id_type: [
            //         { required: true, message: '请选择证件类型', trigger: 'change' }
            //     ],
            //     id_number: [
            //         { required: true, pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: '请填写证件号', trigger: 'blur' }
            //     ], 
            //     mobile: [
            //         { required: true, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请填写手机号', trigger: 'blur' }
            //     ],
            //     sex: [
            //         { required: true, message: '请选择性别', trigger: 'blur,change' }
            //     ],
            //     birthdaytime: [
            //         { required: true, type:'date', message: '请选择生日', trigger: 'blur,change' }
            //     ],
            //     period: [
            //         { required: true, message: '请选择保险期间', trigger: 'change' }
            //     ],
            //     pay_period: [
            //         { required: true, message: '请选择交费期间', trigger: 'change' }
            //     ],
            //     premium: [
            //         { required: true, message: '请填写保费', trigger: 'blur' }
            //     ],
            //     amount: [
            //         { required: true, message: '请填写', trigger: 'blur' }
            //     ],
            //     type: [
            //         { required: true, message: '请选择', trigger: 'change' }
            //     ],
            // }
        }
    },
    components: {
        productTitle
    },
    computed: {
        slidetoggle(){
            return this.$store.state.sildeshow
        },
        hasagent(){
            if(this.agent.eid){
                return false
            }else{
                return true
            }
        },
        hasapp(){
            if(this.applicant.customer_id){
                return false
            }else{
                return true
            }
        },
        hasben(){
            if(this.benefit.customer_id){
                return false
            }else{
                return true
            }
        },
        hasIdCard(){
            if(this.applicant.id_type == '身份证'){
                //this.applicant_number = true
                return true
            }else{
                return false
                //this.applicant_number = false
            }
        },
        canImport(){
            if(this.applicant.customer_id&&this.agent.eid){
                return false
            }else{
                return true
            }
        },
    },
    watch:{
        proTableList:function(val,oldval){
            console.log(val)
            var _length = val.length;
            if(_length > 0){
                this.policyform.premium = 0
                this.pay_period_disable = false
                for(var i = 0;i<_length;i++){
                    //this.policyform.premium = this.formatFloat(this.policyform.premium + this.formatFloat(val[i].premium,2),2)
                    this.policyform.premium = this.formatFloat(this.policyform.premium,val[i].premium)
                    //console.log(this.formatFloat(val[i].premium,2)) 
                }
            }
        }
    },
    mounted () {
      this.cominit() 
      this.orglistinit()
      this.getAllPayPeriod()
      this.getAllPeriod()
      new Promise((resolve, reject) => {
                let _params = {
                    'yid': sessionStorage.getItem('id'),
                }
                getInfo(_params).then(response => {
                    if(response.data.err == 0){
                        this.isOffice = response.data.data.account_type == 'office' ? true : false
                    }
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
        }).then(()=>{
            this.getEntering()
        });
        if(this.isOffice){
            this.location = 1
        }else{
            this.location = 2
        }
      
      //console.log(checkIdCard('230781198502174736'))
      //console.log(this.formatFloat(0,23.56)) 
    },
    methods: {
        removeInsured(index){
            let _id = this.insuredList[index].customer_id
            if(this.proTableList.length > 0){
                for(let i = 0 ,len = this.proTableList.length;i<len;i++){
                    if(this.proTableList[i].customer_id == _id){
                        this.$Message.error('不能删除，需修改相应险种！')
                        return false
                    }
                }
            }
            this.insuredList.splice(index,1)
        },
        asApplationChange(value){
            if(value){
                this.insuredForm.home_address = this.applicant.home_address
            }else{
                this.insuredForm.home_address = ''
            }
        },
        editbenefitlist(index){
            let _obj = Object.assign({}, this.benefitdata[index])  
            this.importTag = false
            this.benefitForm = Object.assign({}, this.benefitForm , _obj) 
            this.benefitdata.splice(index,1) 
        },
        edit_pro(index){
            let _obj = Object.assign({}, this.proTableList[index]) 
            this.ageTag = false
            this.proList = Object.assign({}, this.proList , _obj) 
            this.proTableList.splice(index,1) 
        },
        benefitToList(){
             this.$refs['benefitForm'].validate((valid) => {
                if (valid) {
                    if( this.benefitdata.length > 0){
                        for(let i = 0,len = this.benefitdata.length ;i<len;i++){
                            if(this.benefitdata[i].id_type == this.benefitForm.id_type&&
                                this.benefitdata[i].id_number == this.benefitForm.id_number&&
                                this.benefitdata[i].name == this.benefitForm.name
                            ){
                                this.$Message.error('导入受益人重复！')
                                return false
                            }
                        }
                    }
                    let _obj = Object.assign({},this.benefitForm)
                    this.benefitdata.push(_obj)
                    this.benefitForm = Object.assign({},this.benefitBase)
                }
            })
        },
        proToList(){
            this.$refs['proList'].validate((valid) => {
                if (valid) {
                    
                    let _index = this.proList.insured_name.split('-')[0]
                    console.log(this.insuredList[_index])
                    let _obj = Object.assign({},this.proList,this.insuredList[_index])
                    console.log(_obj)
                    this.proTableList.push(_obj)
                    this.$refs['proList'].resetFields();
                    this.proList = Object.assign({},this.proListBase)
                    // setTimeout(()=>{
                    //     this.proList = Object.assign({},this.proListBase)
                    //     console.log('settime')
                    // },300)
                    // console.log(123)
                        
                }
            })
        },
        insuredChange(val){
            if(this.ageTag){
                console.log(val)
                let _index = val.split('-')[0]
                let _obj = this.insuredList[_index]
                console.log(_obj)
                if(_obj.insured_id_type == '身份证'){
                    if(_obj.insured_id_number&&_obj.insured_id_number.length ==18){
                        let _birth = util.GetBirthday(_obj.insured_id_number)
                        var birthDate = new Date(_birth);
                        var nowDateTime = new Date();
                        var age = nowDateTime.getFullYear() - birthDate.getFullYear();
                        //再考虑月、天的因素;.getMonth()获取的是从0开始的，这里进行比较，不需要加1
                        if (nowDateTime.getMonth() < birthDate.getMonth() || (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime.getDate() < birthDate.getDate())) {
                            age--;
                        }
                        console.log(age)
                        if(age >= 0 ){
                            if(this.proList.agearry){
                                if(this.proList.agearry.length <= 1){
                                    let _obj = {
                                        label:age+'岁',
                                        value:age+''
                                    }
                                    this.proList.agearry = []
                                    this.proList.agearry.push(_obj)
                                    this.proList.limit_age = age+''
                                }else{
                                    this.proList.limit_age = age+''
                                } 
                            }else{
                                let _obj = {
                                    label:age+'岁',
                                    value:age+''
                                }
                                this.proList.agearry = []
                                this.proList.agearry.push(_obj)
                                this.proList.limit_age = age+''
                            }
                        }
                    }
                }else{
                    this.proList.limit_age = ''
                }
            }else{
                this.ageTag = true
            }
            
        },
        editInsured(index){
            let _id = this.insuredList[index].customer_id
            if(this.proTableList.length > 0){
                for(let i = 0 ,len = this.proTableList.length;i<len;i++){
                    if(this.proTableList[i].customer_id == _id){
                        this.$Message.error('不能编辑被保人，需修改相应险种！')
                        return false
                    }
                }
            }
            let _obj = this.insuredList[index]
            _obj.id_effect_datetime = _obj.id_effect_date
            _obj.insured_birthdaytime = _obj.insured_birthday
            this.importTag = false
            this.insuredForm = Object.assign({},_obj)
            this.insuredList.splice(index,1)
        },
        insuredToList(){
            this.$refs['insuredForm'].validate((valid) => {
                if (valid) {
                    if( this.insuredList.length > 0){
                        if(this.policyform.policy_type == '个人保险单'&&this.insuredList.length == 1){
                            this.$Message.error('个人保险单只能有一个被保人！')
                            return false
                        }
                        for(let i = 0,len = this.insuredList.length ;i<len;i++){
                            if(this.insuredList[i].insured_id_type == this.insuredForm.insured_id_type&&
                                this.insuredList[i].insured_id_number == this.insuredForm.insured_id_number&&
                                this.insuredList[i].insured_name == this.insuredForm.insured_name
                            ){
                                this.$Message.error('导入被保人重复！')
                                return false
                            }
                        }
                    }
                    
                    let _obj = Object.assign({},this.insuredForm)
                    console.log(this.insuredForm)
                    console.log(_obj)
                    this.insuredList.push(_obj)
                    this.$refs['insuredForm'].resetFields();
                    this.insuredForm = Object.assign({},this.insuredFormBase)
                } else {
                   
                }
            })
            
        },
        importEmp(index){
            if(this.location == 1){
                this.entering = Object.assign(this.entering,this.enteringList[index])
            }else{
                this.agent = Object.assign(this.agent,this.enteringList[index])
            }
            this.importEntering = false
        },
        importEnter(location){
            this.importEntering = true
            this.location = location
            this.searchEntering = ''
            this.getEntering(true)
        },
        enterPageChange(p){
            this.enteringPage = p
            this.getEntering()
        },
        getEntering(tag){
            
            if(tag) this.enteringPage = this.enterCurrent = 1

            let _params = {
                location: this.location,
                page:this.enteringPage ,
                keyword:this.searchEntering
            }
            
            getEmployee(_params).then(res=>{
                if(res.data.err == 0){
                    console.log(res.data.data.list)

                    if(this.isOffice&&this.location == 1){
                        let _data = res.data.data.list
                        this.entering.job_code = _data.job_code
                        this.entering.name = _data.name
                    }else{
                        this.enteringList = res.data.data.list.map(item =>{
                            item.eid = item.id
                            return item
                        })
                        this.enterTotal =  res.data.data.total
                    }
                    
                }
            })
        },
        benefitTypeChange(value){
            if(value == '身份证'){
                this.benefitIdChange(this.benefitForm.id_number)
            }
        },
        insuredTypeChange(value){
            if(value == '身份证'){
                this.idCardInsuredChange(this.insuredForm.insured_id_number,this.insuredForm)
            }
        },
        applicantIdTypeChange(value){
            if(value == '身份证'){
                this.idcardchange(this.applicant.id_number,this.applicant)
            }
        },
        benefitIdChange(e){ 
            if(e){
                let _idNumber   
                if(typeof(e) != 'string'&&e){
                    _idNumber = e.target.value
                }else{
                    _idNumber = e
                }      
                let _length = _idNumber.length
                if( _length == 18){
                    var _sex = util.Getsex(_idNumber)+''
                    this.$set(this.benefitForm,'sex',_sex)
                }
            }    
        },
        natureChange(value){
            if(value != 3){
                this.policyform.nature_remark = ''
            }
        },
        benefitreChange(value){
            if(this.importTag){
                if(value){
                    if(value == '本人'){
                        let _obj = {}
                        _obj.name = this.applicant.name
                        _obj.id_type = this.applicant.id_type
                        _obj.id_number = this.applicant.id_number
                        _obj.sex = this.applicant.sex
                        _obj.mobile = this.applicant.mobile
                        let _items = Object.assign({},this.benefitForm,_obj)
                        console.log(_items)
                        this.$set(this,'benefitForm',_items)
                    }else{
                        let _obj = {}
                        _obj.name = ''
                        _obj.id_type = '身份证'
                        _obj.id_number = ''
                        _obj.sex = ''
                        _obj.mobile = ''
                        _obj.relation = value
                        let _items = Object.assign({},_obj)
                        console.log(_items)
                        this.$set(this,'benefitForm',_items)
                    }
                }
                
            }else{
                this.importTag = true
            }
            
        },
        insuredRelationChange(value){
            if(this.importTag){
                if(value == '本人'){
                    let _obj = {}
                    _obj.insured_name = this.applicant.name
                    _obj.insured_id_type = this.applicant.id_type
                    _obj.insured_id_number = this.applicant.id_number
                    _obj.insured_sex = this.applicant.sex
                    _obj.insured_birthday = this.applicant.birthday
                    _obj.insured_birthdaytime = this.applicant.birthday
                    _obj.id_effect_datetime = this.applicant.id_effect_datetime
                    _obj.id_effect_date = this.applicant.id_effect_date
                    _obj.id_effect_long = this.applicant.id_effect_long
                    _obj.marital = this.applicant.marital
                    _obj.nationality = this.applicant.nationality
                    _obj.education = this.applicant.education
                    _obj.height = this.applicant.height
                    _obj.weight = this.applicant.weight
                    _obj.insured_mobile = this.applicant.mobile
                    _obj.com_name = this.applicant.com_name
                    _obj.profession = this.applicant.profession
                    _obj.postcode = this.applicant.postcode
                    _obj.email = this.applicant.email
                    _obj.home_address = this.applicant.home_address
                    let _items = Object.assign({},this.insuredForm,_obj)
                    console.log(_items)
                    this.$set(this,'insuredForm',_items)
                    this.idCardInsuredChange(this.applicant.id_number,this.insuredForm)
                }else{
                    let _obj = {}
                    _obj.insured_name = ''
                    _obj.insured_id_type = '身份证'
                    _obj.insured_id_number = ''
                    _obj.insured_sex = ''
                    _obj.insured_mobile = ''
                    _obj.id_effect_long = '0'
                    _obj.insured_relation = value
                    //let _items = Object.assign({},this.insuredForm,_obj)
                    //console.log(_items)
                    this.$set(this,'insuredForm',_obj)
                }
            }else{
               this.importTag = true
               if(value == '本人'){
                    let _obj = {}
                    _obj.insured_name = this.applicant.name
                    _obj.insured_id_type = this.applicant.id_type
                    _obj.insured_id_number = this.applicant.id_number
                    _obj.insured_sex = this.applicant.sex
                    _obj.insured_birthday = this.applicant.birthday
                    _obj.insured_birthdaytime = this.applicant.birthday
                    _obj.id_effect_datetime = this.applicant.id_effect_datetime
                    _obj.id_effect_date = this.applicant.id_effect_date
                    _obj.id_effect_long = this.applicant.id_effect_long
                    _obj.marital = this.applicant.marital
                    _obj.nationality = this.applicant.nationality
                    _obj.education = this.applicant.education
                    _obj.height = this.applicant.height
                    _obj.weight = this.applicant.weight
                    _obj.insured_mobile = this.applicant.mobile
                    _obj.com_name = this.applicant.com_name
                    _obj.profession = this.applicant.profession
                    _obj.postcode = this.applicant.postcode
                    _obj.email = this.applicant.email
                    _obj.home_address = this.applicant.home_address
                    let _items = Object.assign({},this.insuredForm,_obj)
                    console.log(_items)
                    this.$set(this,'insuredForm',_items)
                    this.idCardInsuredChange(this.applicant.id_number,this.insuredForm)
                }
            }
            
        },
        periodModalChange(){
            this.periodModal = false
        },
        pay_periodModalChange(){
            this.pay_periodModal = false
        },
        getAllPayPeriod(){
            new Promise((resolve, reject) => {
                get_pay_period().then(response => {
                    console.log(response.data)
                    if (response.data.err == 0) {               
                        this.allPay_period = response.data.data;
                        
                        
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },
        getAllPeriod(){
            new Promise((resolve, reject) => {
                get_period().then(response => {
                    console.log(response.data)
                    if (response.data.err == 0) {               
                        this.allPeriod = response.data.data;
                        
                        
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },
        getSearchPro(){
            this.proPage = 1
            this.nowPage = 1
            this.getpro()
        },
        proPageChange(page){
            this.proPage = page
            this.nowPage = page
            this.getpro()
        },
        proPageSizeChange(pagesize){
            this.proPageSize = pagesize
        },
        pageFirendChange(){

        },
        openFirendModal(index,type){
            this.friendType = type
            this.firendIndex = index
            this.party_modal = true
            this.firendTag = true
            if(this.applicant.customer_id&&this.agent.eid){
                this.getbenefit()
            }    
        },
        openProModal(){
            //this.proArrayTag = index
            if(this.proList.is_main){
                this.mainTag = this.proList.is_main
            }else{
                this.mainTag = 0
            }
            
            this.searchpro = ''
            this.proPage = 1
            this.nowPage = 1
            this.getpro()
                            
            this.importPro = true
        },
        delProItem(index){
            if(this.insurancesArray.length == 1){
                this.insurancesArray = []
                let _obj = Object.assign({},this.insurancesItem)
                this.insurancesArray.push(_obj)
            }else{
                this.importTag = false
                this.insurancesArray.splice(index,1)
            }
            
        },
        delBenefitItem(index){
            if(this.beneficiaries.length == 1){
                this.beneficiaries = []
                let _obj = Object.assign({},this.baseBenefit)
                this.beneficiaries.push(_obj)
            }else{
                this.importTag = false
                this.beneficiaries.splice(index,1)
            }
        },
        openPeriodModal(){
            this.periodModal = true
        },
        openPayperiodModal(){
            this.pay_periodModal = true
        },
        orglistinit(){
            new Promise((resolve, reject) => {
            let _params = {
                name:''
            }
            getListByName(_params).then(response => {
                    console.log(response.data)
                    if (response.data.err == 0) {               
                        this.orglist = response.data.data;
                        
                        
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },
        relationCurrentChange(currentRow,oldCurrentRow){
            console.log(currentRow)
            console.log(oldCurrentRow)

            this.currentRow = currentRow
            console.log(this.currentRow)
            console.log(this.applicant.customer_id)
            this.importctminfo(this.currentRow._id,this.applicant.customer_id).then( (data) =>{ 
                this.insured = data
                this.insured.sex = this.insured.sex.toString()
                this.insured.birthdaytime = this.insured.birthday
            })
        },
        //新增关系人
        addrelationbtn(){
            console.log(this.applicant.customer_id)
            if(!this.applicant.customer_id){
                this.$Message.error('请先导入被保人')
            }else{
                this.re_canedit = false
            }
            
        },
        editrelationbtn(){
            if(!this.applicant.customer_id){
                this.$Message.error('请先导入被保人')
            }else{
                this.re_canedit = false
            }
        },
        //取消新增
        cancelrelation(){
            this.re_canedit = true
            this.$refs['insured'].resetFields()
            this.insured = {
                id_type:'身份证'
            }
        },
        saverelation(){
            this.import_party()
        }, 
        pageChange(page){
            this.apppage = this.customerForm.page = page
            this.getcustomer()
        },
        tofixed2(number){
            var num1=Number(number).toFixed(3);
            num1 = num1.substring(0,num1.lastIndexOf('.')+3);
            return num1
        },
        formatFloat(oldnmuber,newnumber){
            var number1 = this.tofixed2(oldnmuber)*100
            var number2 = this.tofixed2(newnumber)*100
            return (number1 + number2) / 100
        },
        cid_change(e){
            if(e.value&&e.label){
                this.policyform.cname = e.label
            }
        },
        cancel_insurances(){
            this.importpro = false
        },
        cancel_party(){
            this.party_modal = false
        },
        edit_party(id,relation){
            this.importctminfo(id).then(data=>{
                console.log(data)
                this.insured = data
                this.insured.relation = relation
                this.insured.sex = this.insured.sex.toString()
                this.insured.birthdaytime = this.insured.birthday
                this.party_modal = true
            })
        },
        import_party(){
            if(this.agent.eid){
                this.insured.agent_id = this.agent.eid
                this.$refs['insured'].validate((valid) => {
                    if (valid) {
                        this.insured.applicant_id = this.applicant.customer_id
                        if(!this.insured.id){
                            //创建客户
                            
                            new Promise((resolve, reject) => {
                                createCustomer(this.insured).then(response => {
                                    console.log(response.data)
                                    if (response.data.err == 0) {                           
                                        this.canedit = true
                                        this.re_canedit = true
                                        //this.party_modal = false
                                        this.getcustomer()
                                        this.getbenefit()
                                    } else {
                                        this.$Message.error(response.data.info);
                                    }
                                    resolve();
                                }).catch(error => {
                                    reject(error);
                                });
                            });
                        }else{
                            // 更新客户
                            this.insured.customer_id = this.insured.id
                            new Promise((resolve, reject) => {
                                updateCustomer(this.insured).then(response => {
                                        console.log(response.data)
                                        if (response.data.err == 0) {                           
                                            this.party_modal = false
                                            this.getbenefit()
                                            this.$Message.success(response.data.info);
                                        } else {
                                            this.$Message.error(response.data.info);
                                        }
                                        resolve();
                                    }).catch(error => {
                                        reject(error);
                                    });
                            });
                        }                       
                    }else{
                        this.$Message.error("请输入正确的信息")
                    } 
                })
            }else{
                this.$Message.error("请先导入业务员信息")
            }
        },
        open_party_modal(){
            let _lengh = this.insurancesArray.length
            let _item = this.insurancesArray[(_lengh - 1)]
            let _last = {}
            _last.insured_name = _item.insured_name
            _last.insured_id_type = _item.insured_id_type
            _last.insured_id_number = _item.insured_id_number
            _last.insured_sex = _item.insured_sex
            _last.insured_mobile = _item.insured_mobile
            _last.limit_age = _item.limit_age
            _last.agearry = _item.agearry
            _last.insured_relation = _item.insured_relation
            let _obj = Object.assign({},this.insurances,_last)
            this.insurancesArray.push(_obj)
            this.importTag = true
        },
        add_insured(){
            this.$refs['insured'].resetFields()
            // delete this.insured.
            this.insured = {
                 id_type:'身份证'
            }
            this.canedit = false
        },
        insured_save(){
            if(this.agent.eid){
                this.insured.agent_id = this.agent.eid
                this.$refs['insured'].validate((valid) => {
                    if (valid) {
                        this.insured.name = this.insured.insured_name
                        this.insured.relation = this.insured.insured_relation
                        this.insured.applicant_id = this.applicant.customer_id
                        if(!this.insured.id){
                            //创建客户
                            
                            new Promise((resolve, reject) => {
                                createCustomer(this.insured).then(response => {
                                        console.log(response.data)
                                        if (response.data.err == 0) {                           
                                            this.canedit = true
                                            this.insured.customer_id = response.data.data
                                        } else {
                                            this.$Message.error(response.data.info);
                                        }
                                        resolve();
                                    }).catch(error => {
                                        reject(error);
                                    });
                            });
                        }else{
                            // 更新客户
                            this.insured.customer_id = this.insured.id
                            new Promise((resolve, reject) => {
                                updateCustomer(this.insured).then(response => {
                                        console.log(response.data)
                                        if (response.data.err == 0) {                           
                                            this.canedit = true
                                        } else {
                                            this.$Message.error(response.data.info);
                                        }
                                        resolve();
                                    }).catch(error => {
                                        reject(error);
                                    });
                            });
                        }                       
                    }else{
                        this.$Message.error("请填写正确信息")
                    } 
                })
            }else{
                this.$Message.error("请先导入业务员信息")
            }
        },

        open_pro_modal(){
            this.$refs['insurances'].resetFields()
            this.$refs['insured'].resetFields()
            this.insured.insured_customer_id = ''
            this.create_or_update = 1
            this.prodatatag = -1
            this.importpro = true
            this.canedit = true
        },
        insured_change(e){
            console.log(e)
            if(e.label&&e.value){
                this.insurances.insured_relation = e.label.split("-")[2]
                
            }            
        },
        pro_change(e){
            console.log(e)
            if(e.value&&e.label){
                this.insurances.name = e.label
                this.get_pro_detail(e.value)
            }       
        },
        get_pro_detail(id){            
            new Promise((resolve, reject) => {
                let _params = {
                    mongo_id:id
                }
                getDetailByIdProduct(_params).then(response => {
                    console.log(response.data)
                    if (response.data.err == 0) {                       
                        this.insurances.cate_one =  response.data.data.cate_one 
                        this.insurances.periodarry = response.data.data.period
                        this.insurances.pay_periodarry = response.data.data.pay_period
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    
                }).catch(error => {
                    reject(error);
                });
            });
        },
        getpro(){
            if(this.policyform.cid){
                new Promise((resolve, reject) => {
                    let _params = {
                        cid :this.policyform.cid,
                        is_main:this.mainTag,
                        keyword:this.searchpro,
                        p:this.proPage,
                        pagesize:this.proPageSize
                    }
                    getListByCompany(_params).then(response => {
                        console.log(response.data)
                        if (response.data.err == 0) {                                                   
                            this.searchProList = response.data.data.list
                            this.prototal = response.data.data.total
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        
                    }).catch(error => {
                        reject(error);
                    });
                });
            }else{
                this.$Message.info("请先在保单信息中选择保险公司!")
                
            }
            
        },
        is_main_change(value){
            
            console.log(value)
        },

        sevebenefit(){

            this.canedit = true
        },
        //编辑受益人
        editbenefit(){
            this.canedit = false
        },
        //新增受益人信息
        addbenefit(){
            this.$refs['benefit'].resetFields()
            this.canedit = false
        },
        //受益方式切换
        benefit_change(value){
            console.log(value)
            if(value == '法定受益'){
                this.benefitdata = []
                this.benefitTag = true;
                this.readonly = true;
            }else{
                this.readonly = false;
                this.benefitForm = [
                    {
                        id_number:'',
                        id_type:'',
                        mobile:'',
                        name:'',
                        order:'',
                        relation:'',
                        scale:'',
                        sex:''
                    }
                ]
                this.benefitTag = false
            }
        },

        cancelbenefitbtn(){
            this.importbenefit = false
        },
        //新增受益人
        importbenfit(){
            let _obj = Object.assign({},this.baseBenefit)
           this.beneficiaries.push(_obj)
           this.importTag = true
        },
        //受益人改变
        bftchange(e){
            console.log(e)
            this.importctminfo(e.value).then(data=>{
                console.log(data)
                this.benefit = data
                this.benefit.customer_id = data.id
                this.benefit.sex = this.benefit.sex.toString()
                this.benefit.birthdaytime = this.benefit.birthday
                this.benefit.relation = e.label.split("-")[2]
            })

        },     
        //导入投保人
        importapp(){
            if(this.customer.customer_id){
                this.applicant = Object.assign({},this.applicant,this.customer)
                this.importcustomer = false
                this.getbenefit()
            }else{
                this.$Message.error("请先选择投保人")
            }
        },
        tableCurrentChange(currentRow,oldCurrentRow){
            this.customerEdit = false
            this.hasctmid = false
            console.log(currentRow)
            console.log(oldCurrentRow)
            this.tableaction = false;
            this.currentRow = currentRow
            console.log(this.currentRow)
            this.importctminfo(this.currentRow._id).then( (data) =>{ 
                console.log(data)
                this.customer = data
                this.customer.customer_id = data.id
                delete this.customer.id
                this.customer.sex = this.customer.sex.toString()
                this.customer.birthdaytime = this.customer.birthday
                if(this.customer.customer_id){
                    if(this.importAppType == 1){
                        //导入投保人
                        this.applicant = Object.assign({},this.applicant,this.customer)
                    }else if(this.importAppType == 2){
                        //导入被保人
                        let _obj ={}
                        _obj.customer_id = this.customer.customer_id
                        _obj.insured_name = this.customer.name
                        _obj.insured_id_type = this.customer.id_type ? this.customer.id_type : '身份证'
                        _obj.insured_id_number = this.customer.id_number
                        _obj.insured_sex = this.customer.sex
                        _obj.insured_birthdaytime = this.customer.birthday
                        _obj.insured_birthday = this.customer.birthday
                        _obj.id_effect_datetime = this.customer.id_effect_datetime ? this.customer.id_effect_datetime : '' 
                        _obj.id_effect_date = this.customer.id_effect_date ? this.customer.id_effect_date : '' 
                        _obj.id_effect_long = this.customer.id_effect_long ? this.customer.id_effect_long : '0'
                        _obj.marital = this.customer.marital ? this.customer.marital : ''     
                        _obj.nationality = this.customer.nationality ? this.customer.nationality : ''     
                        _obj.education = this.customer.education ? this.customer.education : ''     
                        _obj.height = this.customer.height ? this.customer.height : ''     
                        _obj.weight = this.customer.weight ? this.customer.weight : ''     
                        _obj.insured_mobile = this.customer.mobile ? this.customer.mobile : ''     
                        _obj.com_name = this.customer.com_name ? this.customer.com_name : ''     
                        _obj.profession = this.customer.profession ? this.customer.profession : ''     
                        _obj.postcode = this.customer.postcode ? this.customer.postcode : ''     
                        _obj.email = this.customer.email ? this.customer.email : ''     
                        _obj.home_address = this.customer.home_address ? this.customer.home_address : ''     
                        this.insuredForm = Object.assign({},this.insuredForm,_obj)
                    }else{
                        //导入受益人
                        this.benefitForm = Object.assign({},this.benefitForm,this.customer)
                    }
                    
                    this.importcustomer = false
                    //this.getbenefit()
                }else{
                    this.$Message.error("请先选择投保人")
                }
            })
        },
        tableProCurrentChange(currentRow,oldCurrentRow){
            let _current = currentRow
            //let _index = this.proArrayTag
            let _obj = this.proList
            //pay_periodarry:[],
            //    periodarry:[],
            _obj.mongo_id = _current.mongo_id
            _obj.name = _current.name
            _obj.is_main = _current.is_main.toString()
            _obj.pay_periodarry = _current.pay_period
            _obj.periodarry = _current.period
            const _list = _current.limit_age_arr.map(item =>{
                return {
                    value:item.toString(),
                    label:item + '岁'
                }
            })
            _obj.agearry = _list
            this.$set(this,'proList',_obj)
            this.importPro = false

        },
        tableFirendCurrentChange(currentRow,oldCurrentRow){
            this.firendTag = false
            let _current = currentRow
            let _index = this.firendIndex
            let _type = this.friendType
            if(_type == 'insured'){
                let _obj =  this.insurancesArray[_index]
                _obj.insured_relation = _current.relation
                this.importctminfo(_current.customer_id).then( (data) =>{ 
                    _obj.insured_name = data.name
                    _obj.insured_id_number = data.id_number
                    _obj.insured_id_type = data.id_type
                    _obj.insured_mobile = data.mobile
                    _obj.insured_sex = data.sex.toString()
                    this.$set(this.insurancesArray,_index,_obj)
                    this.party_modal = false
                })
            }else{
                let _obj = this.beneficiaries[_index]
                _obj.relation = _current.relation
                this.importctminfo(_current.customer_id).then( (data) =>{ 
                    _obj.name = data.name
                    _obj.id_number = data.id_number
                    _obj.id_type = data.id_type
                    _obj.mobile = data.mobile
                    _obj.sex = data.sex.toString()
                    this.$set(this.beneficiaries,_index,_obj)
                    this.party_modal = false
                })
            }
            
        },
        //获取投保人详细信息
        importctminfo(id,type){
            return new Promise((resolve, reject) => {
                let _params = {
                    agent_id:this.agent.eid,
                    customer_id:id,
                    applicant_id:type?type:0
                }
                getDetailById(_params).then(response => {
                    console.log(response.data)
                    if (response.data.err == 0) {                                                   
                        resolve(response.data.data)
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //保存客户
        savecustomer(){
            if(this.agent.eid){
                this.customer.agent_id = this.agent.eid
                this.$refs['customer'].validate((valid) => {
                    if (valid) {
                        if(!this.customer.customer_id){
                            //创建客户
                            new Promise((resolve, reject) => {
                                createCustomer(this.customer).then(response => {
                                        console.log(response.data)
                                        if (response.data.err == 0) {                           
                                            this.canedit = true
                                            //this.customer.customer_id = response.data.data
                                            this.apppage = 1
                                            this.getcustomer()
                                            this.customerEdit = true
                                        } else {
                                            this.$Message.error(response.data.info);
                                        }
                                        resolve();
                                    }).catch(error => {
                                        reject(error);
                                    });
                            });
                        }else{
                            // 更新客户
                            new Promise((resolve, reject) => {
                                updateCustomer(this.customer).then(response => {
                                        console.log(response.data)
                                        if (response.data.err == 0) {                           
                                            this.canedit = true
                                            this.apppage = 1
                                            this.getcustomer()
                                            this.customerEdit = true
                                        } else {
                                            this.$Message.error(response.data.info);
                                        }
                                        resolve();
                                    }).catch(error => {
                                        reject(error);
                                    });
                            });
                        }                       
                    }else{
                        this.$Message.error("请填写正确信息")
                    } 
                })
            }else{
                this.$Message.error("请先导入业务员信息")
            }
        },
        //新增客户
        addcustomerbtn(){
            this.canedit = false
            this.$refs['customer'].resetFields();
            this.customer = {
                id_type:'身份证'
            }
        },
        //取消新增客户
        cancelcustomer(){
            this.$refs['customer'].resetFields();
            this.canedit = true 
            this.customer = {
                id_type:'身份证'
            }
        },
        //关闭投保人
        cancel(){
            this.importcustomer = false
        },
        idcardchange(e,obj){
            let _idNumber
            if(typeof(e) != 'string'){
                _idNumber = e.target.value
            }else{
                _idNumber = e
            }
            if(obj.id_type == '身份证'){           
                let _length = _idNumber.length
                if( _length == 18){
                    obj.birthdaytime = util.GetBirthday(_idNumber)
                    obj.birthday = util.GetBirthday(_idNumber)
                    var _sex = util.Getsex(_idNumber)+''
                    this.$set(obj,'sex',_sex)
                }
            }
        },
        idCardInsuredChange(e,obj,index){
            if(obj.insured_id_type == '身份证'&&e){
                let _idNumber 
                if( typeof(e) != 'string'){
                    _idNumber = e.target.value
                }else{
                    _idNumber = e
                }           
                let _length =_idNumber.length
                if( _length == 18){
                    let _birth = util.GetBirthday(_idNumber)
                    var _sex = util.Getsex(_idNumber)+''
                    obj.insured_sex = _sex
                    obj.insured_birthday = _birth
                    obj.insured_birthdaytime = _birth
                    // var birthDate = new Date(_birth);
                    // var nowDateTime = new Date();
                    // var age = nowDateTime.getFullYear() - birthDate.getFullYear();
                    // //再考虑月、天的因素;.getMonth()获取的是从0开始的，这里进行比较，不需要加1
                    // if (nowDateTime.getMonth() < birthDate.getMonth() || (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime.getDate() < birthDate.getDate())) {
                    //     age--;
                    // }
                    // console.log(age)
                    // if(obj.agearry.length <= 1){
                    //     let _obj = {
                    //         label:age+'岁',
                    //         value:age+''
                    //     }
                    //     obj.agearry = []
                    //     obj.agearry.push(_obj)
                    //     obj.limit_age = age+''
                    // }else{
                    //     obj.limit_age = age+''
                    // }
                }
            }
        },
        //请求firend
        // getbenefit(){
        //     new Promise((resolve, reject) => {
        //         let _params = {
        //             agent_id:this.agent.eid,
        //             applicant_id:this.applicant.customer_id
        //         }
        //         getFriend(_params).then(response => {
        //                 console.log(response.data)
        //                 if (response.data.err == 0) {                           
        //                     this.firendlist = response.data.data;
        //                 } else {
        //                     this.$Message.error(response.data.info);
        //                 }
        //                 resolve();
        //             }).catch(error => {
        //                 reject(error);
        //             });
        //     });
        // },
        cominit(){
            console.log(this.$refs)
            new Promise((resolve, reject) => {
                let _params = {
                    name:''
                }
                parteGetByName(_params).then(response => {
                        console.log(response.data)
                        if (response.data.err == 0) {                           
                            this.comoptions = response.data.data;
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
            });
        },
        surebtn(){

        },
        companychange(item){
            //console.log(item)
            this.policyform.cname = item.label
        },
        //删除被保人
        delinsured(index){           
            this.policyDetail.insureds.splice(index,1)
            console.log(this.policyDetail.insureds.length)
            if(this.policyDetail.insureds.length == 0){
                this.addinsured()
            }
        },
        //追加被保人
        addinsured(){
            this.policyDetail.insureds.push(
                {
                    relation:'本人',
                    canedit:true,
                    name:'',
                    id_type:'身份证',
                    id_number:'',
                    mobile:'',
                    sex:'',
                    birthday:'',
                    com_name:'',
                    profession:'',
                    insurances:[
                        {
                            mongo_id:'',
                            name:'',
                            period:'',
                            period_arry:[],
                            pay_period:'',
                            pay_period_arry:[],
                            premium:'', 
                            type:'保险金额',
                            amount :''
                        }
                    ],
                    beneficiary_type:'指定受益',
                    beneficiary:[
                        {
                            name:'',
                            id_type:'身份证',
                            id_number:'',
                            mobile:'',
                            relation:'',
                            sex:'',
                            birthday:'',
                            order:'',
                            scale:''
                        }
                    ]
                }
            )
        },
        //添加险种
        addpro(pindex,sindex){
            this.policyDetail.insureds[pindex].insurances.push(
                {
                    mongo_id:'',
                    name:'',
                    period:'',
                    period_arry:[],
                    pay_period:'',
                    pay_period_arry:[],
                    premium:'', 
                    type:'保险金额',
                    amount :''
                }
            )
        },
        //时间转换
        datachange(date,obj,param){
            obj[param] = date
            if(param == 'underwrite_date'){
                if(obj['settlement_datetime'] == ''){
                    obj['settlement_datetime'] = date
                }
                
            }
        },
        importEmployee(type){
            this.importemployee = true
            this.importtype = type
        },
        importapplicant(type){
            this.importcustomer = true
            this.hasctmid = true
            this.importAppType = type
            this.getcustomer()
        },
        //获取险种
        proGetByName(){

        },
        //获取客户信息
        getcustomer(cl){
            this.customerEdit = true
            if(cl){
                this.apppage = this.customerForm.page = 1
            }
            if(!this.agent.eid){
                this.$Message.error("请先导入业务员信息")
                return false
            }
            new Promise((resolve, reject) => {
                this.customerForm.agent_id = this.agent.eid
                getApplicant(this.customerForm).then(response => {
                    console.log(response.data)
                    if (response.data.err == 0){
                           this.appCustomerList = response.data.data.list
                           this.apptotal = response.data.data.total                
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },

        //导入员工
        impempbtn(id){
            this.getemployee(id)
        },
        //获取员工详细信息
        getemployee(id){
            new Promise((resolve, reject) => {
                let _params = {
                    id:id
                }
                getById(_params).then(response => {
                    console.log(response.data)
                    if (response.data.err == 0){
                       if(this.importtype == 1){
                           this.entering = Object.assign(this.entering,response.data.data)
                       }
                       if(this.importtype == 2){
                           this.agent = Object.assign(this.agent,response.data.data)
                       }
                       this.importemployee = false
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //员工搜索 by name
        searchemp(){
           // this.searchemploy
           this.tableloading = true
            new Promise((resolve, reject) => {
                let _params = {
                    name:this.searchemploy
                }
                getByName(_params).then(response => {
                    this.tableloading = false
                    if (response.data.err == 0) {
                        this.emplist = response.data.data
                    } else {
                        this.$Message.error('请先填写姓名');
                    }
                    resolve();
                }).catch(error => {
                    this.tableloading = false
                    reject(error);
                });
            });
        },
        sendpolicy(){
            //'entering','agent','policyform','applicant'
            let successtag = 0
            let formarry = ['entering','agent','policyform1','policyform','applicant',]
            for(var i=0;i<formarry.length;i++){
                this.$refs[formarry[i]].validate((valid) => {
                if (valid) {  

                } else {
                    if(formarry[i] == 'entering' || formarry[i] == 'agent' ){
                        this.$Message.error('请完善业务员信息！')
                        this.tabName = 'name'
                        
                    }
                    if(formarry[i] == 'policyform1'){
                         this.$Message.error('请完善机构归属信息！')
                         this.tabName = 'name'
                    }
                    if(formarry[i] == 'policyform'){
                         this.$Message.error('请完善保单信息！')
                         this.tabName = 'policyform'
                    }
                    if(formarry[i] == 'applicant'){
                         this.$Message.error('请完善投保人信息！')
                         this.tabName = 'applicant'
                    }
                    successtag++
                }
                })
                if(successtag>0){
                    return false
                }
            }
            
            if(this.insuredList.length == 0){
                this.$Message.error('请完善被保人信息！')
                this.tabName = 'insuredForm'
                return false
            }

            if(this.proTableList.length == 0){
                this.$Message.error('请完善险种信息！')
                this.tabName = 'proList'
                return false
            }

            if(this.beneficiary_type == '指定受益'&&this.benefitdata.length == 0){
                this.$Message.error('指定受益至少有一个受益人！')
                this.tabName = 'benefit'
                return false
            }

            console.log(successtag)
            if(successtag == 0){
                
                this.spinShow = true
                let _obj = {}
                _obj.entering = this.entering
                _obj.agent = this.agent
                _obj.policyform =this.policyform
                _obj.policyform.policy_type = this.policyform.policy_type == '个人保险单' ? 1 : 2
                _obj.applicant = this.applicant
                _obj.insurances  = this.proTableList
                _obj.insurances.map(item=>{
                    delete item.agearry
                    delete item.pay_periodarry
                    delete item.periodarry
                    return item
                })
                _obj.beneficiary_type = this.beneficiary_type
                _obj.beneficiaries = this.benefitdata
                console.log(_obj)
                new Promise((resolve, reject) => {
                    policyCreate_v2(_obj).then(response => {
                        console.log(response.data)
                        if (response.data.err == 0) {
                            this.$Message.success(response.data.info);
                            this.$router.push({ name: 'underwrite_policy' });                           
                        } else {
                            this.spinShow = false
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        this.spinShow = false
                        reject(error);
                    });
                }); 
                   // _obj.insureds = this.policyDetail.insureds
                
            }else{
                this.$Message.error("请完善必填信息！");
            }
            // if(successtag == 0){
            //     let _insureds = this.policyDetail.insureds
            //     for(var i=0;i<_insureds.length;i++){
            //         if(_insureds[i].relation == "本人"){
            //             _insureds[i].name = this.applicant.name
            //             _insureds[i].id_type  = this.applicant.id_type 
            //             _insureds[i].id_number  = this.applicant.id_number 
            //             _insureds[i].mobile = this.applicant.mobile
            //             _insureds[i].sex  = this.applicant.sex 
            //             _insureds[i].birthday = this.applicant.birthday
            //             _insureds[i].birthdaytime = this.applicant.birthdaytime
            //             _insureds[i].com_name = this.applicant.com_name
            //             _insureds[i].profession = this.applicant.profession 
            //         }
            //     }
            // }
            // for(var i =0 ;i<this.$refs['insureds'].length;i++){
            //     this.$refs['insureds'][i].validate((valid) => {
            //     if (valid) {                   
            //         } else {
            //             console.log(i)
            //             successtag++
            //         }
            //     })
            // }
            // console.log(successtag)
            // if(successtag == 0){
            //     this.spinShow = true
            //     let _obj = {}
            //     _obj.entering = this.entering
            //     _obj.agent = this.agent
            //     _obj.policyform =this.policyform
            //     _obj.applicant = this.applicant
            //     _obj.insureds = this.policyDetail.insureds
            //     console.log(_obj)
            //     console.log(JSON.stringify(_obj))
            //     new Promise((resolve, reject) => {
            //         policyCreate_v2(_obj).then(response => {
            //             console.log(response.data)
            //             if (response.data.err == 0) {
            //                 this.$Message.success(response.data.info);
            //                 this.$router.push({ name: 'underwrite_policy' });                           
            //             } else {
            //                 this.spinShow = false
            //                 this.$Message.error(response.data.info);
            //             }
            //             resolve();
            //         }).catch(error => {
            //             this.spinShow = false
            //             reject(error);
            //         });
            //     });  
            // }else{
            //     this.$Message.error("请完善必填信息！");
            // }                     
        },
        resetform(){
            this.$refs['entering'].resetFields();
            this.$refs['agent'].resetFields();
            this.$refs['policyform'].resetFields();
            this.$refs['applicant'].resetFields();
            //this.$refs['insureds'][0].resetFields();
            //this.$refs['insureds'].resetFields();
            //console.log(this.$refs['insureds'])
            for(var i =0 ;i<this.$refs['insureds'].length;i++){
                this.$refs['insureds'][i].resetFields();
            }
            console.log(this.$refs['insureds'][0])
            console.log(this.$refs)
        },
        cancelpolicy(){
            this.$router.push({'name':'underwrite_policy'});
        }
    }
}
</script>
